Reputation: 1142
If I start the application over Wi-Fi and I switch to 3G, it prints 0, 15, so it's mobile network but I don't know why that subtype means. Then I switch back to Wi-Fi and it prints 0, 3 for a second (Mobile network, NETWORK_TYPE_UMTS) and displays that I'm connected to a mobile network on my UI, finaly it connects to Wi-Fi and it prints 1, 0. So what does 15 means? Docs doesn't say what are these values.
if (networkInfo != null && networkInfo.isConnected()) {
int netType = networkInfo.getType();
int netSubtype = networkInfo.getSubtype();
Log.d("Receiver", String.valueOf(netType));
Log.d("Receiver", String.valueOf(netSubtype));
if (netType == ConnectivityManager.TYPE_WIFI) {
Log.i("Receiver", "WiFi");
} else if (netType == ConnectivityManager.TYPE_MOBILE
&& netSubtype == TelephonyManager.NETWORK_TYPE_UMTS
&& !telephonyManager.isNetworkRoaming()) {
Log.i("Receiver", "Mobile");
}
}
http://developer.android.com/reference/android/net/NetworkInfo.html#getSubtype()
Upvotes: 2
Views: 4536
Reputation: 26198
So what does 15 means?
It means how fast your internet connection through the mobile connection is, so constant 15 is actually HSPA+
HSPA+ (also called Evolved HSPA or 4G) is a further evolution of
HSPA that offers data speeds of up to 42 Mbps.
you can go to this post
sample code:
if(type==ConnectivityManager.TYPE_WIFI){
return true;
}else if(type==ConnectivityManager.TYPE_MOBILE){
switch(subType){
case TelephonyManager.NETWORK_TYPE_1xRTT:
return false; // ~ 50-100 kbps
case TelephonyManager.NETWORK_TYPE_CDMA:
return false; // ~ 14-64 kbps
case TelephonyManager.NETWORK_TYPE_EDGE:
return false; // ~ 50-100 kbps
case TelephonyManager.NETWORK_TYPE_EVDO_0:
return true; // ~ 400-1000 kbps
case TelephonyManager.NETWORK_TYPE_EVDO_A:
return true; // ~ 600-1400 kbps
case TelephonyManager.NETWORK_TYPE_GPRS:
return false; // ~ 100 kbps
case TelephonyManager.NETWORK_TYPE_HSDPA:
return true; // ~ 2-14 Mbps
case TelephonyManager.NETWORK_TYPE_HSPA:
return true; // ~ 700-1700 kbps
case TelephonyManager.NETWORK_TYPE_HSUPA:
return true; // ~ 1-23 Mbps
case TelephonyManager.NETWORK_TYPE_UMTS:
return true; // ~ 400-7000 kbps
/*
* Above API level 7, make sure to set android:targetSdkVersion
* to appropriate level to use these
*/
case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11
return true; // ~ 1-2 Mbps
case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
return true; // ~ 5 Mbps
case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
return true; // ~ 10-20 Mbps
case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
return false; // ~25 kbps
case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
return true; // ~ 10+ Mbps
// Unknown
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
default:
return false;
}
Have a look at the NETWORK_TYPE_HSPAP
it has a connection speed of 10-20 Mbps
Upvotes: 5
Reputation: 134664
There's an accompanying method called getSubtypeName()
which will return a human-readable value describing the subtype.
EDIT: Digging through the source, it seems that it will be one of the TelephonyManager.NETWORK_TYPE_*
constants (e.g. NETWORK_TYPE_GPRS
)
Upvotes: 2