Trouble understanding CONNECTIVITY_ACTION extras
<p>To be notified of network connections and disconnects, and to then know if my application can connect to the internet, I register a <code>ConnectionManager.CONNECTIVITY_ACTION</code> receiver. At present, I check if the phone has an active network connection like so:</p>

<pre><code>if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
    // no connection!
} else {
    NetworkInfo activeNetInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
    if (activeNetInfo != null &amp;&amp; activeNetInfo.isConnectedOrConnecting()) {
        // active connection!
    } else {
        // no connection!
    } 
}
</code></pre>

<p>However, I think I'm doing this wrong because my app can sometimes misreport the phone's connectivity status. Reading the documentation for <code>EXTRA_NETWORK_INFO</code>, it seems to indicate that if the value returned for this extra is null, then there is no connection: "...if the connectivity manager is attempting to connect (or has already connected) to another network, the NetworkInfo for the new network is also passed as an extra" (http://developer.android.com/reference/android/net/ConnectivityManager.html#CONNECTIVITY_ACTION).</p>

<p>However in instances where my app misreports connectivity, just prior to receiving the <code>CONNECTIVITY_ACTION</code> broadcast, <code>getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo()</code> returns a <code>NetworkInfo</code> object whose <code>isConnectedOrConnecting()</code> check returns true. So the phone appears to be connected, but the <code>NetworkInfo</code> returned via the <code>CONNECTIVITY_BROADCAST</code> is null.</p>

<p>What am I doing wrong in my <code>CONNECTIVITY_ACTION</code> receiver code? Should I not check the value of <code>EXTRA_NETWORK_INFO)</code>? Can I simply rely on <code>EXTRA_NO_CONNECTIVITY</code>?</p>

<p>Any help is appreciated!</p>
