'App is scanning too frequently' with ScanSettings.SCAN_MODE_OPPORTUNISTIC 'App is scanning too frequently' with ScanSettings.SCAN_MODE_OPPORTUNISTIC android android

'App is scanning too frequently' with ScanSettings.SCAN_MODE_OPPORTUNISTIC


Android 7 prevents scan start-stops more than 5 times in 30 seconds. The bad side is, it doesn't return an error, instead just prints a log. The app thinks the scan is started but it's not actually started back at the ble stack. Also it converts long running scans to opportunistic scan with an intent of preventing abusive apps. The duration is 30 minutes for a long running scan.

These changes are undocumented, mentioned in this post: https://blog.classycode.com/undocumented-android-7-ble-behavior-changes-d1a9bd87d983