HAxxor HAxxor - 2 years ago 307
Android Question

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

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

Answer Source

Use a WebClient on your web view as follow :

webView.setWebViewClient(new WebViewClient(){

public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
   // Do something
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download