How can I get and change wifi standard, which I'm using now in my android device. For example: IEEE 802.11b or IEEE 802.11g or IEEE 802.11n. If this is possible.
调用 ScanedWifiInfo 的supportedStandards
private ScanedWifiInfo getActiveScanedWifiInfo(){ if(!NetworkUtils.isWifiConnected(HwContext.getContext())) return null ; List<ScanedWifiInfo> scans = CacheArrayManager.getInstance(HwContext.getContext()).getScanWifiInfos(); ScanedWifiInfo scanedWifiInfo = null; if (scans != null && scans.size() > 0){ for (ScanedWifiInfo scan : scans){ if (scan.isActive()){ scanedWifiInfo = scan; break; } } } return scanedWifiInfo; }
getActiveScanedWifiInfo().supportedStandards;
返回值为字符串
String tmpRadio = ""; if (A) { tmpRadio += "a"; if (N) { tmpRadio += "/n"; } if (AC) { tmpRadio += "/ac"; } } else { tmpRadio += "b"; if (G) { tmpRadio += "/g"; } if (N) { tmpRadio += "/n"; } } radio += tmpRadio; supportedStandards = tmpRadio;
也可以使用获取
public void getWifiStandard(Context context){ WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); try { WifiInfo wifiInfo = wifiManager.getConnectionInfo(); Log.e("WifiStandard",wifiInfo.getWifiStandard()+""); }catch (Exception e){ Log.e("WifiStandard",e.toString()); } }