P.S my English very bad and I have mistakes in text))) please sorry! The problem is that when a new page is loaded, WEBVIEW shows the previous one, and if it is not loaded at all or loaded with errors, then it shows the message The web page is not available, which I would not want to see at all, but hide or replace it with my own, how is this possible to implement? https://cloud.mail.ru/public/321U/4DU3gj9dy this is my Android Studio project. archive password : myapps123
TO FIND and see the error rebuild the project and follow the steps below: Install the app to your mobile phone/
You can call loadErrorPage(view) function in the onReceivedError function.
The following code will load the error content you need to show.Here i am load the html file with loadDataWithBaseURL.
public void loadErrorPage(WebView webview){
if(webview!=null){
String htmlData ="<html><body><div align=\"center\" >"This is
the description for the load fail : "+description+"\nThe failed url is
: "+failingUrl+"\n"</div></body>";
webview.loadUrl("about:blank");
webview.loadDataWithBaseURL(null,htmlData, "text/html", "UTF-8",null);
webview.invalidate();
}
}
You can write onReceivedError like that :
WebView wv = (WebView) findViewById(R.id.webView);
wv.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
suåper.onReceivedError(view, errorCode, description, failingUrl);
//call loadErrorPage function here
}
});