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 use a WebView to display some internet content on one of our app's
I know how to use UIWebView and can invoke a WebView if it is
use Rack::Static, :urls => ['/stylesheets', '/images'], :root => 'public' run proc { |env| [200,
My app uses a WebView widget to load ads from Google AdManager. AdManager gives
In my app I have a UIWebView which loads different rtf files. I use
The problem: I want to use a WebView to enable dynamic loading of ads
I would like to check reachability before/when a webView is shown in my app.
I've to switch a part of my app: I will implement a web view
When ever I try to use a web view it gives me a null
A client has an iOS app that makes fairly heavy use of UiWebViews (with

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.