I am loading a document from google docs into my webview. The problem I see is that when user launch the app and is not connected to network, sees the following screen:
Now if he connects to the network, what is the way to open that link inside webview without re-launching the app. Clicking that link in the webview is one option but can I provide some better user friendly way to reload page in webview if this kind of scenario happens?
You can catch network error in WebViewClient, and show layout which custom by youself, like this:
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(final WebView view, int errorCode, String description,
final String failingUrl) {
//control you layout, show something like a retry button, and
//call view.loadUrl(failingUrl) to reload.
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With