0

My app is displaying a web page inside a WebView. If the web page is not there i receive a file not found error page (404).

I'm trying to override a WebViewClient's onReceivedError method. I logout the error code and description but nothing is getting logged out.

Any ideas why?

Eventually i want to redirect somewhere else if i get a 404.

Thanks in advance.

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

        webView = (WebView) findViewById(R.id.webView1);
                webView.getSettings().setJavaScriptEnabled(true);



                MyWebViewClient mwvc = new MyWebViewClient();
                webView.setWebViewClient(mwvc);

                webView.loadUrl(compUrl);



            }

            private class MyWebViewClient extends WebViewClient{

                @Override
                public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

                    Log.e(TAG, "errorCode = " + errorCode + "errorDescription = " + description);

                    super.onReceivedError(view, errorCode, description, failingUrl);
                }

            }
turtleboy
  • 8,210
  • 27
  • 100
  • 199
  • So it's not going in onReceivedError at all? – MysticMagicϡ Dec 03 '13 at 13:53
  • @Anamika No it's not. There is no logging. I've looked at the WebViewClient API and it states the following. "Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable). The errorCode parameter corresponds to one of the ERROR_* constants." So if the resource is not there, then this method will not execute! – turtleboy Dec 03 '13 at 14:05
  • Ok.. Check [this](http://stackoverflow.com/a/13197346/1777090) if it helps. – MysticMagicϡ Dec 03 '13 at 14:11
  • Check out [issue 32755](https://code.google.com/p/android/issues/detail?id=32755) – rds Jul 25 '14 at 13:16

0 Answers0