How do you detect the network connection type on Android?
Is it through ConnectivityManager.getActiveNetworkInfo().getType()
, and the answer is limited to Wifi and mobile?
How do you detect the network connection type on Android?
Is it through ConnectivityManager.getActiveNetworkInfo().getType()
, and the answer is limited to Wifi and mobile?
Currently, only MOBILE and WIFI is supported. Take a look and human readable type function.
You can use getSubtype() for more details. Check out slide 9 here: http://dl.google.com/io/2009/pres/W_0300_CodingforLife-BatteryLifeThatIs.pdf
// Only update if WiFi or 3G is connected and not roaming
int netType = info.getType();
int netSubtype = info.getSubtype();
if (netType == ConnectivityManager.TYPE_WIFI) {
return info.isConnected();
} else if (netType == ConnectivityManager.TYPE_MOBILE
&& netSubtype == TelephonyManager.NETWORK_TYPE_UMTS
&& !mTelephony.isNetworkRoaming()) {
return info.isConnected();
} else {
return false;
}