简体   繁体   English

主动Android wifi扫描

[英]Active Android wifi scan

As far as I understood from the previous posts, time for completing an active wifi scan (startScanActive()) should be around 0.7 s but on my phone it remains the same as for a passive scan (startScan ()). 据我从以前的帖子中了解到,完成主动wifi扫描(startScanActive())的时间应在0.7 s左右,但在我的手机上,它与被动扫描(startScan())相同。 Also I can not see hidden SSIDs.Is there are any other way to get a wifi scan results and hidden SSIDs quicker? 我也看不到隐藏的SSID,还有其他方法可以更快地获取wifi扫描结果和隐藏的SSID吗?

Some background on active and passive scans: 主动和被动扫描的一些背景:

Active scan scans all the non-passive channels actively by sending probe requests so the time spent on each channel is short. 主动扫描通过发送探测请求来主动扫描所有非被动通道,因此花费在每个通道上的时间很短。 Passive scan is used generally for DFS channels where active scanning is not allowed and hence a device has to wait for one beacon interval to find all APs on that channel. 被动扫描通常用于不允许进行主动扫描的DFS信道,因此设备必须等待一个信标间隔才能找到该信道上的所有AP。 Overall scanning passive channels should take more time than scanning active channels 整体扫描被动通道应比扫描主动通道花费更多时间

In your case, you should be able to use in the android developer API reference to get scan results: 就您而言,您应该能够在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 is not an exposed API in android reference. 在Android参考中, startScanActive不是公开的API。 I recommend not using it. 我建议不要使用它。 If you must use it, refer this - https://github.com/mozilla/MozStumbler/issues/40 如果必须使用它,请参考此-https://github.com/mozilla/MozStumbler/issues/40

Refs: 参考:

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 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM