0

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

4

1 回答 1

0

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

主动扫描通过发送探测请求主动扫描所有非被动通道,因此在每个通道上花费的时间很短。被动扫描通常用于不允许主动扫描的 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 参考中的公开 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

于 2018-07-31T21:35:09.603 回答