Reputation: 13474
Whether or not the device has 3g/data activated. Any idea of what's happening? Thank you
My code:
public boolean isConnected3G(){
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] networks = cm.getAllNetworkInfo();
for (NetworkInfo ni : networks)
if ("MOBILE".equalsIgnoreCase(ni.getTypeName())){
Log.d(TAG,""+ni.isConnected());
if (ni.isConnected())
return true;
}
return false;
}
Upvotes: 1
Views: 515
Reputation: 320
Try to use NetworkInfo ni = cm.getActiveNetworkInfo() instead of cm.getAllNetworkInfo(); and check the network information
Upvotes: 1