Android 7+ - Scanning stops and returns no beacons after an hour app is in background and mobile is idle


#1

Problem Statement:

Continuous beacon scanning has an impact when android mobile is kept idle for more than an hour. Observed that beacon scanning stopped and “onBeaconsDiscovered” method is not invoked.

We are using Estimote SDK version 1.4.5

Implementation detail:

This is how we start the Beacon manager:

        beaconManager = new BeaconManager(context);
        //Scans every second for second
        beaconManager.setForegroundScanPeriod(1500, 0);
        beaconManager.setBackgroundScanPeriod(1500, 0);
        beaconManager.setRangingListener(
                new BeaconRangingListener() {
                    @Override
                    public void onBeaconsDiscovered(BeaconRegion region, List<Beacon> list) {
                        updateBeaconsFoundToListeners(list);
                    }
                });

       beaconManager.connect(new ServiceReadyCallback() {
            @Override
            public void onServiceReady() {
                if (beaconManager != null) {
                    beaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
                }![Screenshot_20190102-224951|281x500](upload://2sxB4RoAMQbMBFbyCeroVdnN0vC.png) 
            }
        });

onBeaconsDiscovered() method does not get called the app is kept in background for more than an hour.

Observed this problem on Android 8+

Logs for reference

In the following pic we can see that, scanning stopped after 22.16 and when i again unlocked the device, it started giving results at 22.43.