我在我的应用程序中监视Kontakt信标,并且我正在使用SpaceListener来了解用户何时进入某个区域以及何时用户放弃了该区域。问题是我不断收到进入区域和放弃区域。 我正在使用该库的3.2.0版本。信标距离我只有1米,信标也都不在我身边。这是正常行为吗?
@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());
}
}
答案 0 :(得分:0)
虽然我不是Kontakt Android SDK的专家,但是当移动设备间歇性地检测到信标时,通常会发生这种问题。这可能有很多原因:
ScanMode.BALANCED
更改为ScanMode.LOW_LATENCY