startScan() in WifiManager deprecated in Android P

EAK TEAM picture EAK TEAM · Mar 8, 2018 · Viewed 18.3k times · Source

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

Answer

marko.tm picture marko.tm · Aug 5, 2018

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