I’m having a problem on Android where I see onExitedRegion
called milliseconds after onEnteredRegion
.
Here is a typical set of events with timestamps:
2016-02-03 10:57:29.975000 ENTER_REGION
2016-02-03 10:57:29.977000 EXIT_REGION
2016-02-03 10:57:36.169000 ENTER_REGION
2016-02-03 10:57:36.170000 EXIT_REGION
2016-02-03 10:57:41.372000 ENTER_REGION
2016-02-03 10:57:50.703000 EXIT_REGION
2016-02-03 10:58:24.943000 ENTER_REGION
2016-02-03 10:58:24.944000 EXIT_REGION
2016-02-03 10:58:26.189000 ENTER_REGION
2016-02-03 10:58:26.190000 EXIT_REGION
You can see that the onExitedRegion
is normally called a few milliseconds after onEnteredRegion
(though in one case it’s 10 seconds later).
I’ve seen this behaviour intermittently on several Android devices, but I’ve recently been testing with a Samsung A3, and on this device it happens continuously.
Here is my configuration in detail:
Samsung A3 running Android 5.01
estimote:sdk:0.9.7@aar
Beacons broadcasting every 450ms
I’m not far from the beacon when this is happening. One possibly salient fact is that my onEnteredRegion
causes ranging to start.
Here is my setup code:
beaconManager = new BeaconManager(context);
beaconManager.setBackgroundScanPeriod(1500, 30000);
beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> list) {
// Start recording ranges.
RangingController.startRangeRecording(region);
}
@Override
public void onExitedRegion(Region region) {
// Stop range recording.
RangingController.stopRangeRecording(region);
}
});
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
beaconManager.startMonitoring(new Region("Region", MY_UUID, null, null));
}
});