Nexus 5, BootstrapNotifier and background mode

138 Views Asked by At

I work on an app that use AltBeacon library. So far, it's wonderful, but now i have a problem with Background mode.

So when i exit my app, i call mBeaconManager.setBackgroundMode(true);. 2 cases :
- I have at least 1 beacon nearby : the method didEnterRegion is well fired and all is good
- If i wait more than 1 hour (1h30 or nearly) without beacon nearby then have one: didEnterRegion is no more fired. I red docs so i understand that it won't be fast, but even after 15 min, nothing happen.

On another device (Nexus 4...) both cases work. Even after 2hours, app killed...etc, didenterRegion is still fired.

So far, Nexus 5 is on Android 5.1.1 and Nexus 4 is on Android 5.1.1 too. Seems to be on Nexus 5 only...

Any idea?

Many thanks

1

There are 1 best solutions below

2
On BEST ANSWER

It could be that on the Nexus 5 the operating system is terminating your app in the background due to low memory or other conditions. You can tell if this is happening by modifying your code to set:

beaconManager.setDebug(true);

Then looking at LogCat while the app in the background. If the app is still running (and waiting for beacon detections), you should see lines like:

Waiting to start full Bluetooth scan for another XXXX milliseconds

If you don't see lines like the above, then this probably indicates the app has been killed by the OS. If this indeed what is happening, a fix to re-launch the app under these conditions was put into a 2.3-beta4 release of the library available here. It is not available in JCenter/Maven yet, but will be when the 2.3 release is out of beta.

One clarification: If you have Android 5.x, the background detections should be very fast. If everything is working properly, you will get a callback from the library within 5 seconds of turning the beacon on.