Scanjob Continues Beign Invoked After The 15 Min Period And Stops When A Region Matches
Solution 1:
Sorry to hear of the trouble. It is unclear precisely what is causing the scans to happen at the unexpected intervals, but I suspect it may have to do with double binding.
A few tips:
Do not bind manually if using Region bootstrap as it does so internally. Remove:
beaconManager.bind(this);
Also remove the following method, moving your range notifier setup to onCreate
onBeaconServiceConnect
Configuration changes must be set up before binding through RegionBootstrap. So move these lines above that line:
beaconManager.setBackgroundScanPeriod(3000l); beaconManager.setBackgroundBetweenScanPeriod(15000l); beaconManager.setRegionStatePersistenceEnabled(false);
Understand that the above background scan periods cannot be respected on Android 8 in the background where between scan periods will be clamped to ~15 secs by the operating system. I would scan in the background for more than 3 secs at a time. Consider keeping the default of 10 secs.
You should avoid using the isAnyConsumerBound() method on Android 8 as the latest library version has a bug making it unreliable on that plaform. (The bug has been fixed awaiting the next release.). Regardless, you should not need this logic and can safely start ranging immediately without that of statement.
Understand that ranging will only give you a single callback at the end of the background scan period. So if you have it set up properly, you will get one ranging callback every 15 minutes in the background.
If you really want constant scanning in the background on Android 8, consider creating a foreground service. Simply having one will unlock the ability to keep your app running indefinitely.
Post a Comment for "Scanjob Continues Beign Invoked After The 15 Min Period And Stops When A Region Matches"