How to check if webview failed to load page (android)?

android

Solution

Use a WebClient on your web view as follow :

webView.setWebViewClient(new WebViewClient(){

@Override public void onReceivedError(WebView view, WebResourceRequest request,
      WebResourceError error) {
    super.onReceivedError(view, request, error);
    // Do something
  }
});

Problem

I have a webview in my app, however sometimes due to connectivity the webview fails to load and I get the default webpage unavailable page. I want to show an alertdialog if the webview failed to load. Is there anyway I can check (maybe in the shouldOverridePageLoad function) that a webview loaded successfully? Thanks again

Original source