Sometimes the active connection is not first in the list, or is inactive or in an error state. This is how I would do it:
NetworkInfo i = conMgr.getActiveNetworkInfo();
if (i == null)
return false;
if (!i.isConnected())
return false;
if (!i.isAvailable())
return false;
return true;
[EDIT 1] Don’t forget to add this permission in the application manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Does this help you?
Emmanuel