title: Using Context.CONNECTIVITY_SERVICE to check for internet connection
body: <p>I am using this code to check for the internet connection:</p>
  
  <pre><code>private boolean checkInternetConnection() {
      ConnectivityManager cm = (ConnectivityManager)
                                getSystemService(Context.CONNECTIVITY_SERVICE);
      // test for connection
      if (cm.getActiveNetworkInfo() != null
              &amp;&amp; cm.getActiveNetworkInfo().isAvailable()
              &amp;&amp; cm.getActiveNetworkInfo().isConnected()) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>but even when I turn off the wifi it still returns true.</p>
  
  <p>Tried both on emulator and device with same result?<br>
  What is wrong ?</p>