Android WebView onReceivedError()

According to documentation and my experience it should work quite fine.
You just have to set your WebClient with overriden method onReceivedError in your WebView.

Here is the snippet from some of my old test app:

 WebView wv = (WebView) findViewById(R.id.webView);
 wv.setWebViewClient(new WebViewClient() {
    @Override
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Log.i("WEB_VIEW_TEST", "error code:" + errorCode);
            super.onReceivedError(view, errorCode, description, failingUrl);
    }
 });

I’ve tested it and it works quite fine. Check your logs and see what kind of code error do you get.
Hope it helps.

Leave a Comment