繁体   English   中英

主动Android wifi扫描

[英]Active Android wifi scan

据我从以前的帖子中了解到,完成主动wifi扫描(startScanActive())的时间应在0.7 s左右,但在我的手机上,它与被动扫描(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()

在Android参考中, startScanActive不是公开的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

暂无
暂无

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

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