Android P 中不推荐使用 WifiManager 中的 startScan() [英] startScan() in WifiManager deprecated in Android P

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

问题描述

如何在没有 mWifimanager.startScan();

谷歌说:

startScan()此方法在 API 级别 P 中已弃用.应用触发扫描请求的功能将在未来版本中移除.

我正在使用的这个 API 级别的通知<代码>列表<扫描结果>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

更新至 2019 年 1 月 12 日:https://issuetracker.google.com/issues/112688545

Update to 12 January 2019 : https://issuetracker.google.com/issues/112688545

推荐答案

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

2018 年 8 月 8 日此处还添加了信息:https://developer.android.com/guide/主题/连接/wifi-scan#wifi-scan-throttling

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

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

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