HAxxor HAxxor - 11 months ago 187
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


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