androidflutteraltbeacon

Beacon scanning delayed in some phones (ex. One plus, some Motorola devices)


I created one app that scan(ranging) beacons in forground, background and also when app is killed. I used altbeacon library for this project. As suggested by davidjyoung the member of altbeacon library, for background scanning I started foreground service.

It works fine in most of the devices very well but in some phones(one plus, xiaomi,some Motorola devices) the gap between getting scanning beacons is very high(sometimes about 50 seconds to 1 minute). Can someone suggest what should I do for the solution?

Please give suggestion.

Thank you in advance.

The code is same for all devices but gap is very high in some phone.


Solution

  • Many Android OEMs customize the Bluetooth stack to save battery and police background activity. This is notoriously true of Xiaomi, OnePlus, Huawei and other Chinese OEMs. There are two main ways in which these changes are made:

    1. OEMs kill apps running in the background. The folks at DontKillMyApp have done a great job of documenting this, and offer some solutions. These solutions typically mean instructing users to go to Android settings to exclude your app from the proprietary background power savers.
    2. OEMs limit the frequency of Bluetooth scans and turn off the radio receiver to block scans when apps are in the background or the screen is off. Excluding your app from background limits as described in your first point may or may not help.

    Unfortunately, if you have gotten users to exclude your app from background restrictions and you still see these issues, there is little that you can do. You may need to redesign your app to work within the limits on these OEMs, block support of your app for phones from these OEMs, or change the user experience to be foreground only for the problematic OEMs. See here for further thoughts on this topic -- and certainly let your boss or project manager know about these limitations.

    One final note: in my experience, Motorola is usually not a problematic OEM. It was once owned by Google, and for many years stayed pretty close to open source Android. If you are seeing problems on Motorola, you may want to look for other causes. Test with the library's reference app and confirm you see the same problems, and test with quality beacons advertising at 10Hz and high transmitter power.