Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

java - startScan() in WifiManager deprecated in Android P

How to get scan result from wifi for example every 3 seconds, without mWifimanager.startScan();

Google says :

startScan() This method was deprecated in API level P. The ability for apps to trigger scan requests will be removed in a future release.

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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

Source: https://issuetracker.google.com/issues/79906367

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...