Skip to content

How can I change the previous web page to my own if it did not load in WEB VIEW?

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? 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/

  1. Start the application.
  2. Open any link on the page.
  3. Turn off the Internet, but do not minimize the application!
  4. Open any link.
  5. Click Reload twice
  6. Turn on the Internet, but do not minimize the application!(hold the home button in tour device 🙂
  7. Block the application accessing to the Internet with a firewall.
  8. Click on the house button in application menu bar. on the screen.
  9. Click Reload and see an error – I want to hide this error or replace it on my screen or page.


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){
                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.loadDataWithBaseURL(null,htmlData, "text/html", "UTF-8",null);

You can write onReceivedError like that :

    WebView wv = (WebView) findViewById(;
     wv.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                suåper.onReceivedError(view, errorCode, description, failingUrl);
           //call loadErrorPage function here