Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6195397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:27:42+00:00 2026-05-24T03:27:42+00:00

I have a application as below that runs as FullScreen.NoTitleBar: public class BrowserActivity extends

  • 0

I have a application as below that runs as FullScreen.NoTitleBar:

public class BrowserActivity extends Activity {
private String lastUrl = "http://www.google.com";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    WebView web = (WebView) findViewById(R.id.webview);

    WebSettings settings = web.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(false);
    settings.setSupportMultipleWindows(false);
    settings.setSupportZoom(false);
    settings.setPluginsEnabled(true);

    web.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            lastUrl = url;
            view.loadUrl(url);
            return true;
        }
    });
    web.setVerticalScrollBarEnabled(false);
    web.setHorizontalScrollBarEnabled(false);

    web.loadUrl(lastUrl);
}
}

The “lastUrl” is used for handle orientation changes and let the user on the same page that he was while navigating.

But my problem is, if the user follow some links then hit the return button, the application just closes instead of returning a page back. How can I handle it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:27:44+00:00Added an answer on May 24, 2026 at 3:27 am

    I solved it by handling returns and keeping track of the URLs visited by the user.

    public class BrowserActivity extends Activity {
        private Stack<String> urls = new Stack<String>();;
    
        private String lastUrl = "http://www.google.com/";
        private WebView web;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.main);
            try {
            web = (WebView) findViewById(R.id.webview);
    
            WebSettings settings = web.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(false);
            settings.setSupportMultipleWindows(false);
            settings.setSupportZoom(false);
            settings.setPluginsEnabled(true);
    
            web.setWebViewClient(new WebViewClient() {
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    urls.push(lastUrl);
                    lastUrl = url;
                    return false;
                }
            });
            web.setVerticalScrollBarEnabled(false);
            web.setHorizontalScrollBarEnabled(false);
    
            web.loadUrl(lastUrl);
        }
    
        public boolean onKeyDown(int keyCode, KeyEvent evt) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                if (urls.size() > 0) {
                    lastUrl = urls.pop();
                    web.loadUrl(lastUrl);
                } else
                    finish();
                return true;
            }
    
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that runs the a command as below: <command> <switches> >&
in my application i have the playvideo page where video will play, below that
I have an application that sends broadcast messages and listens for response packets. Below
I have a applet that runs with no issue in asp.net web application ...
I have an application that runs in the background only (by specifying LSBackgroundOnly in
I have a powershell script that runs a console .exe application. The console application
I have a system application, that runs as a collection on 12 processes on
I have created an application that compiles and runs like a charm on OS-X.
I have a Zend Framework application structure as below: /application /library /Zend /Core /Filter
I have a grid view control in my application. Please see the below code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.