在Android P中弃用WifiManager中的startScan() [英] startScan() in WifiManager deprecated in Android P

查看:525
本文介绍了在Android P中弃用WifiManager中的startScan()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从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 using List<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."

来源:
https://issuetracker.google.com/issues/79906367

编辑8-Aug-2018:此处还添加了信息:
https://developer.andro id.com/guide/topics/connectivity/wifi-scan

Edit 8-Aug-2018: Information has been added also here: https://developer.android.com/guide/topics/connectivity/wifi-scan

这篇关于在Android P中弃用WifiManager中的startScan()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆