激活Android wifi扫描



据我从之前的帖子中了解,完成主动wifi扫描(startScanActive())的时间应该在0.7秒左右,但在我的手机上,它仍然与被动扫描(startScan())相同。我也看不到隐藏的ssid。还有其他方法可以更快地获得wifi扫描结果和隐藏ssid吗?

主动和被动扫描的一些背景:

主动扫描通过发送探测请求主动扫描所有非被动通道,因此在每个通道上花费的时间很短。被动扫描通常用于不允许主动扫描的DFS通道,因此设备必须等待一个信标间隔才能找到该通道上的所有ap。总体扫描无源通道应该比扫描有源通道花费更多的时间

在你的情况下,你应该能够使用android开发者API参考来获得扫描结果:

Request a scan for access points. Returns immediately. The availability of the 
results is made known later by means of an asynchronous event sent on 
completion of the scan.
To initiate a Wi-Fi scan, declare the Manifest.permission.CHANGE_WIFI_STATE 
permission in the manifest, and perform these steps:
Invoke the following method: ((WifiManager) 
getSystemService(WIFI_SERVICE)).startScan()
Register a BroadcastReceiver to listen to SCAN_RESULTS_AVAILABLE_ACTION.
When a broadcast is received, call: ((WifiManager) 
getSystemService(WIFI_SERVICE)).getScanResults()

startScanActive在android reference中不是一个公开的API。我建议不要使用它。如果您必须使用它,请参考此- https://github.com/mozilla/MozStumbler/issues/40

:

https://developer.android.com/reference/android/net/wifi/WifiManager startScan ()https://developer.android.com/reference/android/net/wifi/WifiManager getScanResults ()https://github.com/mozilla/MozStumbler/issues/40

最新更新