title: How to show a message in android when internet access not available in webview and hide the url?
body: <p>How to show a message in an android app when internet access not available in webview and hide the URL?   I don't want to display the URL and progressbar if the internet connection is not available.</p>
  
  <p>This is my code. Please provide me the correct code. I am a beginner to android.</p>
  
  <pre><code>public class WebViewClientDemoActivity extends Activity {
      /** Called when the activity is first created. */
  
      WebView web;
      ProgressBar progressBar;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          web = (WebView) findViewById(R.id.webview01);
          progressBar = (ProgressBar) findViewById(R.id.progressBar1);
  
          web.setWebViewClient(new myWebClient());
          web.getSettings().setJavaScriptEnabled(true);
          web.loadUrl("http://www.vijaytutorials.com/mo");
      }
  
      public class myWebClient extends WebViewClient
      {
          @Override
          public void onPageStarted(WebView view, String url, Bitmap favicon) {
              // TODO Auto-generated method stub
              super.onPageStarted(view, url, favicon);
          }
  
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
              // TODO Auto-generated method stub
  
              view.loadUrl(url);
              return true;
  
          }
  
          @Override
          public void onPageFinished(WebView view, String url) {
              // TODO Auto-generated method stub
              super.onPageFinished(view, url);
  
              progressBar.setVisibility(View.GONE);
          }
      }
  
      // To handle "Back" key press event for WebView to go back to previous screen.
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) 
      {
          if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; web.canGoBack()) {
              web.goBack();
              return true;
          }
          return super.onKeyDown(keyCode, event);
      }
  }
  </code></pre>