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

  • Home
  • SEARCH
  • 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 6198207
In Process

The Archive Base Latest Questions

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

I use a webview in my app. Code: webView.getSettings().setJavaScriptEnabled(true); webView.setWebChromeClient(new WebChromeClient() { public void

  • 0

I use a webview in my app.

Code:

    webView.getSettings().setJavaScriptEnabled(true);

    webView.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress)
        {
            activity.setTitle("Loading...");
            activity.setProgress(progress * 100);

            if(progress == 100){

                activity.setTitle(R.string.app_name);
                //view.canGoBack();
            }
        }
    });


    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // TODO Auto-generated method stub
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // TODO Auto-generated method stub
            view.canGoBack();
            super.onPageFinished(view, url);
        }

    });
    //The URL that webview is loading
    webView.loadUrl(uri);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
        webView.goBack();
        return true;            
            }
        return super.onKeyDown(keyCode, event);
}

when I press the back button pressed, the app is crashes and generates an error in logcat

07-29 12:47:56.341: ERROR/AndroidRuntime(10567): Uncaught handler: thread main exiting due to uncaught exception
07-29 12:47:56.401: ERROR/AndroidRuntime(10567): java.lang.NullPointerException
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at com.MyDemo.WebViewActivity.onKeyDown(SiteViewActivity.java:74)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.view.KeyEvent.dispatch(KeyEvent.java:1069)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.app.Activity.dispatchKeyEvent(Activity.java:1980)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1724)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2424)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2394)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1726)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.os.Looper.loop(Looper.java:123)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at android.app.ActivityThread.main(ActivityThread.java:3948)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at java.lang.reflect.Method.invokeNative(Native Method)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at java.lang.reflect.Method.invoke(Method.java:521)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
07-29 12:47:56.401: ERROR/AndroidRuntime(10567):     at dalvik.system.NativeStart.main(Native Method)

I want to go back to previous web page in webview.

  • 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:57:25+00:00Added an answer on May 24, 2026 at 3:57 am

    maybe this post will help you:

    How to go back to previous page if back button is pressed in WebView?

    Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an Android app which displays content in a WebView. The
When my app starts up, I post a login request to a web service
In my app i need to open the bank's page, to make the user
This is an iPad app. You press one of two buttons and it presents
This is a Cocoa app I am working on. I'm trying to embed a
I'm developping an iPhone app on which I want to be able to programmatically
I have a native iPhone app that just loads a website using UIWebView .
I'm trying to implement the 1.6 Mobile Facebook API ( http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Mobile_1_6.swc ) into an
For starters, I am not a programmer, my wife is making me learn how
I have an Alert method set in the main class. Which is then called

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.