title: Detect if Android device has Internet connection
body: <p>I need to tell if my device has Internet connection or not. I found many answers like:</p>
  
  <pre><code>private boolean isNetworkAvailable() {
      ConnectivityManager connectivityManager 
           = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
      return activeNetworkInfo != null;
  }
  </code></pre>
  
  <p><sup>(Taken from <a href="https://stackoverflow.com/questions/4238921/detect-whether-there-is-an-internet-connection-available-on-android">Detect whether there is an Internet connection available on Android</a>.)</sup></p>
  
  <p>But this is not right, for example if I'm <strong>connected to a wireless network which doesn't have Internet access</strong>, this method will return true… <strong>Is there a way to tell if the device has Internet connection and not if it is only connected to something?</strong></p>