我可以枚举所有的WiFi网络的范围(使用startScan + SCAN_RESULTS_AVAILABLE_ACTION + getScanResults),并得到他们的SSID和BSSID值,但我无法弄清楚如何确定每个网络的安全类型。
I can enumerate all wifi networks in range (using startScan + SCAN_RESULTS_AVAILABLE_ACTION + getScanResults) and get their SSID and BSSID values, but I can't figure out how to determine the security type of each network.
在我的主要目标:
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
registerReceiver(scanReceiver, intentFilter);
((WifiManager)getSystemService(Context.WIFI_SERVICE)).startScan();
在我scanReceiver对象:
In my scanReceiver object:
public void onReceive(Context c, Intent intent) {
if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(intent.getAction())){
mainObject.scanComplete();
}
}
和又在我的主要目标:
public void scanComplete()
{
List<ScanResult> networkList = ((WifiManager)getSystemService.(Context.WIFI_SERVICE)).getScanResults();
for (ScanResult network : networkList)
{
<do stuff>
}
}
在code工作范围内的scanComplete最终被调用,我可以成功地枚举所有附近的WiFi网络,并得到他们的SSID和BSSID,但我无法弄清楚如何确定其安全性类型。
The code works insofar that scanComplete eventually gets called, and I can successfully enumerate all nearby wifi networks and get their SSID and BSSID, but I can't figure out how to determine their security type.
有没有办法做到这一点?
Is there a way to do this?
在此先感谢。
您需要解析ScanResult的能力字符串中的scanComplete方法。按照 Android开发者文档,:
You need to parse the ScanResult's capabilities string in the scanComplete method. According to the Android developer documentation, :
ScanResult.capabilities描述了认证,密钥管理,并且 加密方案支持的接入点
ScanResult.capabilities describes the authentication, key management, and encryption schemes supported by the access point.
您也许可以利用 - 或者至少是作为一个例子 - 在AccessPointState类可用静态辅助方法。
You might be able to make use of -- or at the very least use as an example -- the static helper methods available in the AccessPointState class.
AccessPointState.getScanResultSecurity AccessPointState.isEnterprise AccessPointState.getScanResultSecurity AccessPointState.isEnterprise