问题描述
如何从wifi获取扫描结果,例如每3秒一次,没有 mWifimanager.startScan();
How to get scan result from wifi for example every 3 seconds, without mWifimanager.startScan();
谷歌说:
startScan()
此方法在API级别P中已弃用。应用程序触发扫描请求的能力将在将来的版本中删除。
注意此API级别我使用
列表< ScanResult> results = mWifiManager.getScanResults();
没有调用 startScan
,该列表包含wifi AP,但它更新非常慢
Notice for this API level i'm usingList<ScanResult> results = mWifiManager.getScanResults();
without calling startScan
, the list contains the wifi AP's but it makes updated very very slow
推荐答案
Google现在已经记录了Android P中startScan()函数的限制:
Google has now documented the limitations for startScan() function in Android P:
我们正在进一步限制应用程序可以请求的扫描次数,以提高网络性能并延长电池寿命。
"We are further limiting the number of scans apps can request to improve network performance and improve battery life.
WifiManager.startScan()用法仅限于:
- 每个前台应用程序每2分钟限制为4次扫描。
- 所有后台应用程序合并为每30分钟一次扫描。
The WifiManager.startScan() usage is limited to:- Each foreground app is restricted to 4 scans every 2 minutes.- All background apps combined are restricted to one scan every 30 minutes."
来源:
编辑8-Aug-2018:此处还添加了信息:
Edit 8-Aug-2018: Information has been added also here:https://developer.android.com/guide/topics/connectivity/wifi-scan
这篇关于在Android P中弃用WifiManager中的startScan()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!