WebViewClient onReceivedError not showing the error

3.1k views Asked by At

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);
                }

            }
0

There are 0 answers