This is not so obvious. Because WebViewClient will open the standard error page anyway, even if you override the onReceivedError method. Therefore, we need to open the user error page after the processing error event.
So, you have to redefine onReceivedError in WebViewClient , then if you are processing the necessary error code (see ERROR_ constants in WebViewClient), you must open a blank page or another page to hide the standard "Web page is not accessible" page.
Something like that:
@Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { if (errorCode == neededErrorCode) { hideErrorPage(view); } } private void hideErrorPage(WebView view) {
source share