title: Detect Internet Connection in Android Application?
body: <p>I have following method, which will check for the Internet connection in the device : </p>
  
  <pre><code>public static boolean checkInternetConnection(Context context) {
      ConnectivityManager connectivityManager = 
              (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  
      if (connectivityManager.getActiveNetworkInfo() != null
              &amp;&amp; connectivityManager.getActiveNetworkInfo().isAvailable()
              &amp;&amp; connectivityManager.getActiveNetworkInfo().isConnected()) {
          return true;
      } else {
          return false;
      }
  
  }
  </code></pre>
  
  <p>But after a while I found out that this method only checks for the Network Connectivity; like the device is connected to a router and the router is ON but no internet is available, this method returns true.</p>
  
  <p>So How to know that there is actual internet or not ?</p>