I am using android beacon library to detect beacons.I have created a service which implements Bootstrap Notifier and It got two methods :
@Override
public void didEnterRegion(Region arg0) {
Log.i(TAG, "A beacon has enter the region .........");
}
@Override
public void didExitRegion(Region arg0) {
Log.i(TAG, "A beacon has exit the region .........");
}
and also :
mAllBeaconsRegion = new Region("all beacons", Identifier.parse(UUID),null, null);
mBeaconManager = BeaconManager.getInstanceForApplication(this);
new BackgroundPowerSaver(this);
bootstrap = new RegionBootstrap(this, mAllBeaconsRegion);
mBeaconManager.setBackgroundScanPeriod(1000l);
mBeaconManager.setBackgroundBetweenScanPeriod(1000l);
My problem is that in some devices beacon exits the region automatically and didExitRegion called and then re-enters in region and didEnterRegion called.It again disconnects automatically.
This is happening in loop. I am testing it with Lollipop.
How can i get rid of this? Please help.
It is important to understand what causes a Region exit. A region exit fires when no advertising packets from a beacon matching a Region object are detected in a 10 second period. There are a number of things that can cause this:
Hardware beacons that do not advertise frequently enough. For best performance, beacons should advertise at a rate of 10 Hz or more. Some manufacturers slow down the advertising rate to save battery, making beacons advertise only every 5 seconds or so. This can cause region exits if some of the packets are missed by the receiver due to radio noise or other issues. To solve this problem, configure your beacon to advertise at least once per second (1 Hz.)
Beacons being on the edge of the radio range of the mobile device. Bluetooth beacons have a varying range of 2-50 meters, depending on the manufacturer, settings, placement and the antenna on the receiving mobile device. If the signal is very weak, detections an be intermittent, causing exits if no packets have been seen in 10 seconds. To fix this, increase the transmitter power of your beacon, or add a software filter to ignore intermittent exit events.
Some mobile devices (e.g. Moto X, Moto G, Nexus 4, Nexus 7) have a hardware flaw where bluetooth and WiFi do not work simultaneously. This can cause the symptoms you describe because it makes beacon detections intermittent. To solve this problem, disable WiFi when looking for beacons on one of these devices.