Ranging stops (or slows) when device in doze

Hi. I’m using the following
SDK 0.16.0
Proximity beacons
OS 3.2.0
Hardware Revision D3.4

My issue is that if I start ranging in a service on android 6+, then the ranging stops when the device goes into doze. Even if I turn battery optimization off, it still stops (or slows considerably).

I’m wondering if anyone knows how to keep ranging active for Android 5+ when the device goes to sleep or doze.

Hi @Pacopag,

the ranging technology is done for foreground working. As said here, you can’t range in background. Only the monitoring technology can be in background.

Thank you for your reply.

I just realized that as long as I don’t call BeaconManager.setForegroundScanPeriod (i.e. use the default), then I CAN use ranging continuously while the device is in doze. I’m watching it happen before my eyes right now. I think it requires battery optimization to be off, but that’s OK for my use case. BUT, I defintely don’t want ranging results every second. Every 10 seconds would be plenty. But as soon as I call setForegroundScanPeriod, then ranging stops working when the device is in doze (I’m calling setRangingInterval before connect…not sure if that matters).

Monitoring in the background while in doze might also be acceptable for me, but I may need to monitor hundreds of regions. Is that reasonable?

It doesn’t seem to me that there is a limit of monitored regions in Android. Just add a region with:


and handle that in you listener mapping each region with an action.

Would there be much overhead in terms of resource usage if I monitor hundreds or thousands of individual beacons?

I also realized that it is not the call to setRangingInterval that causes it to stop in doze, but rather a call to setRangingInterval with the waitTimeMillis set to something non-zero. i.e. as long as waitTimeMillis is 0, then it continues to range even when the device is asleep.

In my opinion, monitoring a region more is adding a software filter to the ble scanning service… But I don’t know exactly…

I think I gotcha. So it would really be a minimal overhead, since a scan is a scan is a scan, and the software is just checking if the discovered devices are in any given region.

Yeah, but need confirmatio from Estimote staff :slight_smile:

Well thank you very much for all your help.