title: android internet connection
body: <p>I am using the following code to see if user have internet connection (WIFI or 3G or Edge).
  Why does some users get "No internet connection" when they do have it?</p>
  
  <pre><code>try{
    ConnectivityManager connec =  (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
              State wifi = connec.getNetworkInfo(1).getState();
  
    if (connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED ||
      connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTING || 
      wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING ) {
      ///HAVE CONNECTION CODE////
              }else if ( connec.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED ||   connec.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED   ) {
      ///NO CONNECTION CODE///
    }
  } catch (Throwable t){
  ///NO CONNECTION CODE///
  }
  </code></pre>