title: Android WebView and internet connection/Wifi error message
body: <p>Hoping someone can help me here as I am really stuck. I have some code for a Android app using WebView. I'm trying to work out how to add some code to check if there is a connection to the internet or wifi. Now I have searched overflow already and tried many different bits of code and nothing has worked for me. Im not an Android dev, just trying to make something for myself and family.
  I would like to display a html page in the app ( error.html ) which will have my custom error message when there is no connection.</p>
  
  <p>Any help would be great. </p>
  
  <pre><code>package com.lotto.lra;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.net.Uri;
  import android.os.Bundle;
  import android.view.KeyEvent;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  public class LottoResultsActivity extends Activity {
  private class HelloWebViewClient extends WebViewClient {
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
  if (Uri.parse(url).getHost().equals("www.mydomain.com")) {
  // This is my web site, so do not override; let my WebView load the page
  return false;
  }
  
  // Otherwise, the link is not for a page on my site, so launch another Activity that     handles URLs
  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  startActivity(intent);
  return true;
  }
  }
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
  if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; mWebView.canGoBack()) {
  mWebView.goBack();
  return true;
  }
  return super.onKeyDown(keyCode, event);
  }
  
  private WebView mWebView;
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedstanceState);
  setContentView(R.layout.main);
  
  mWebView = (WebView) findViewById(R.id.webview);
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.loadUrl("http://www.mydomain.com/LRA/");
  mWebView.setWebViewClient(new HelloWebViewClient());
  mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  }       
  }
  </code></pre>