title: Hide Webview errors in android
body: <p>I have not found any specific solution for hiding the default errors shown by webviews in Android. I am able to display my own custom error messages by trapping specific errors by their error codes. </p>
  
  <p>The problem here is that before my Custom error messages show up I see the WebView errors for a split second and then my custom errors are displayed after that. </p>
  
  <p>Following is a piece of code that does the error handling and display my own custom error messages :</p>
  
  <pre><code>protected void onPostExecute(String S) {
  
          mWebView.setWebViewClient(new WebViewClient() { 
  
  
              @Override
              public void onReceivedError(WebView view, int errCode, String errDescription, String failingUrl ) {
  
                  view.clearView();
  
                  Toast.makeText(getApplicationContext(), "Error code is "+errCode, Toast.LENGTH_SHORT).show();
                  if(errCode == -2 || errCode == -8) {
                      view.loadData("There seems to be a problem with your Internet connection. Please try later", "text/html", "UTF-8");
                  }
  
                  if(errCode == -14) {
                      view.loadData("Page cannot be found on server", "text/html", "UTF-8");
                  }
  
              }
  
          });
  
          mWebView.loadUrl(url);
  
          ShowProgress.dismiss();
      } 
  </code></pre>
  
  <p>Can someone suggest any modifications or advice on how hiding webview errors can be achieved and only my custom error messages get displayed? Thank you for stopping by and reading this post.</p>