I want to hide that error and only show a blank page and a dialog.
How can I hide it?
It is not so obviously. Because WebViewClient will open standart error page anyway, even if you override onReceivedError method. So we need to open custom error page after handle error event.
So, you should override onReceivedError in WebViewClient, then if you handle needed error code (see ERROR_ constants in WebViewClient) you should open blank page or another page to hide standart Android "Web page not available" page.
Something like this:
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
if (errorCode == neededErrorCode) {
hideErrorPage(view);
}
}
private void hideErrorPage(WebView view) {
// Here we configurating our custom error page
// It will be blank
String customErrorPageHtml = "<html></html>";
view.loadData(customErrorPageHtml, "text/html", null);
}
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