在我的应用中,我使用ScanResult来获取网络列表。如何找到网络的带宽(比如22MHz或40MHz等)?
答案 0 :(得分:0)
您可以使用以下功能获取带宽范围,但不能获得确切的带宽。
public static void printBandwidthOfConnection(Context context){
NetworkInfo info = Connectivity.getNetworkInfo(context);
Log.i("Range",rangeOfConnection(info.getType(),info.getSubtype())));
}
/**
* Check if the connection is fast
* @param type
* @param subType
* @return string
*/
public static String rangeOfConnection(int type, int subType){
if(type==ConnectivityManager.TYPE_WIFI){
return "wifi";
}else if(type==ConnectivityManager.TYPE_MOBILE){
switch(subType){
case TelephonyManager.NETWORK_TYPE_1xRTT:
return "50-100 kbps";
case TelephonyManager.NETWORK_TYPE_CDMA:
return " 14-64 kbps";
case TelephonyManager.NETWORK_TYPE_EDGE:
return "50-100 kbps";
case TelephonyManager.NETWORK_TYPE_EVDO_0:
return "400-1000 kbps";
case TelephonyManager.NETWORK_TYPE_EVDO_A:
return "600-1400 kbps";
case TelephonyManager.NETWORK_TYPE_GPRS:
return "100 kbps";
case TelephonyManager.NETWORK_TYPE_HSDPA:
return "2-14 Mbps";
case TelephonyManager.NETWORK_TYPE_HSPA:
return "700-1700 kbps";
case TelephonyManager.NETWORK_TYPE_HSUPA:
return "1-23 Mbps"
case TelephonyManager.NETWORK_TYPE_UMTS:
return "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 " 1-2 Mbps";
case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
return "5 Mbps";
case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
return "10-20 Mbps";
case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
return "25 kbps";
case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
return "10+ Mbps";
default:
return null;
}
}else{
return null;
}
}