title: ConnectivityManager getActiveNetworkInfo() is always null even with data traffic active
body: <p>i'm working on a android project and i had the need to check for internet connection. i searched the web and i found a solution here on stackoverflow. However, i'm having problems on checking the internet state. I already searched everywhere but i can't find any solution for my problem.</p>
  
  <p>Here is the manifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>
  
  <p>Here is the code for checking if internet is connected:</p>
  
  <pre><code>cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
  if (cm != null) {
  NetworkInfo ni = cm.getActiveNetworkInfo();
  isConnected = (ni != null &amp;&amp; ni.isAvailable() &amp;&amp; ni.isConnected()) ? true : false;
  }
  </code></pre>
  
  <p>The problem is that even with TYPE_MOBILE data traffic active the ni variable is always null. To access the operators internet traffic is this the correct way of testing it? Or i have to use TelephonyManager?
  It's wierd because i used getNetworkInfo()[] and debugged it, the HSPA for TYPE_MOBILE appears there but isAvalaible is always false and getState() = DISCONNECTED. However i have operator's data traffic enabled and working (in other applications)</p>
  
  <p><strong>[EDIT]</strong>: by the way im testing it directly in the device not in emulator :).</p>
  
  <p>Thanks in advance. Regards.</p>