We suppose that a url is already loaded (Let’s call it the original url).
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
webView.loadUrl("file:///android_asset/missing.html");
}
});
I have created my own error page to prevent the “web page not available message” to appear.
The app must reload the webview every time it is resumed. So i have the following lines of code:
@Override
protected void onResume() {
super.onResume();
webView.reload();
}
The problem here is that when the error page is loaded (for example when the user is not connected to the internet), and then a connection is available again and the user resumes the app, the original url is not loaded (which seems logic, the current now is missing.html). But is this a nice approach? Any suggestions for the problem?
There is also a refresh button if the user wants to reload the content. Same issue here.
I’d examine internet connectivity in onResume() like suggested on http://developer.android.com/training/basics/network-ops/managing.html