I am monitoring Kontakt beacons in my app and I am using SpaceListener in order to know when the user enter a region and when user abandoned the region. The problem is that I received constantly and region entered and region abandoned. I am using version 3.2.0 of the library. Beacons are only a 1m of me and neither the beacons neither me are moving. Is this the normal behavior?
@Override
public void onCreate() {
super.onCreate();
proximityManager = new ProximityManager(this);
proximityManager.setIBeaconListener(createIBeaconListener());
proximityManager.setSpaceListener(new SpaceListener() {
@Override
public void onRegionEntered(IBeaconRegion region) {
Log.d(TAG,"onRegionEntered");
}
@Override
public void onRegionAbandoned(IBeaconRegion region) {
Log.d(TAG,"onRegionAbandoned");
}
@Override
public void onNamespaceEntered(IEddystoneNamespace namespace) {
}
@Override
public void onNamespaceAbandoned(IEddystoneNamespace namespace) {
}
});
proximityManager.configuration()
.scanMode(ScanMode.BALANCED)
.activityCheckConfiguration(ActivityCheckConfiguration.MINIMAL)
.forceScanConfiguration(ForceScanConfiguration.MINIMAL);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
proximityManager.connect(new OnServiceReadyListener() {
@Override
public void onServiceReady() {
proximityManager.startScanning();
}
});
return START_STICKY;
}
private IBeaconListener createIBeaconListener() {
return new SimpleIBeaconListener() {
private SFBeacon nearestBeacon;
@Override
public void onIBeaconDiscovered(IBeaconDevice iBeaconDevice, IBeaconRegion region) {
Log.d(TAG,"----------------------------------------------");
Log.d(TAG,"Detected: "+iBeaconDevice.getUniqueId()+" "+iBeaconDevice.getProximityUUID().toString()+" "+iBeaconDevice.getMajor()+" "+iBeaconDevice.getMinor());
}
}
While I am not an expert on the Kontakt Android SDK, this kind of problem typically happens when the beacon is detected only intermittently by the mobile device. This can have a number of causes:
ScanMode.BALANCED
toScanMode.LOW_LATENCY