判断wifi是2.4G还是5G
1.WifiInfo 源码:
int mFrequency=wifiInfo.getFrequency();
如果
mFrequency 大于 2400 且 小于 2500 为2.4G
mFrequency 大于4900 且小于 5900 为 5G
/**
* @hide
* TODO: makes real freq boundaries
*/
public boolean is24GHz() {
return ScanResult.is24GHz(mFrequency);
}
/**
* @hide
* TODO: makes real freq boundaries
*/
public boolean is5GHz() {
return ScanResult.is5GHz(mFrequency);
}
2. ScanResult 代码
public static boolean is24GHz(int freq) {
return freq > 2400 && freq < 2500;
}
/**
* @hide
* TODO: makes real freq boundaries
*/
public static boolean is5GHz(int freq) {
return freq > 4900 && freq < 5900;
}
今天多一点积累,明天少一分烦恼