我的信标在 didRangeBeaconsInRegion 上几秒钟后消失,但我靠近我的信标
My beacon disappears after few seconds on didRangeBeaconsInRegion but i am near to my beacon
注意:
我检查了多个设备仍然没有改善,我将我的信标频率设置为 2000 毫秒,但仍然面临这个问题
我遇到了一个问题,信标检测稳定了几秒钟,但之后它消失了,然后它检测到了信标。我对这个建议很感兴趣,感谢代码示例!!
代码
this.beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.setForegroundScanPeriod(500);
beaconManager.setForegroundBetweenScanPeriod(500);
enableBackgroundMode(true);
beaconManager.setAndroidLScanningDisabled(true);
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_UID_LAYOUT));
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_URL_LAYOUT));
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_TLM_LAYOUT));
this.beaconManager.setDebug(true);
this.beaconManager.bind(this);
this.beaconManager.addRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
Log.e(TAG, "beacons size=>" + beacons.size());
if (beacons.size() > 0) {
//my code
}
}
});
LogCat:
10-12 12:33:48.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:49.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:50.356 12357-12881/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@26eeaf3b
10-12 12:33:50.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:51.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:52.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:52.391 12357-12880/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@26eeaf3b
10-12 12:33:53.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:54.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:54.396 12357-12880/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@26eeaf3b
10-12 12:33:55.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:56.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:57.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:58.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:59.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:34:00.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:34:01.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:34:02.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
尝试删除以下行:
beaconManager.setForegroundScanPeriod(500);
beaconManager.setForegroundBetweenScanPeriod(500);
如果没有这些行(使用默认设置),库将在前台不断扫描。有了这些线,它一次只会扫描半秒,这很可能会错过您的信标的传输并导致检测丢失。
注意: 我检查了多个设备仍然没有改善,我将我的信标频率设置为 2000 毫秒,但仍然面临这个问题
我遇到了一个问题,信标检测稳定了几秒钟,但之后它消失了,然后它检测到了信标。我对这个建议很感兴趣,感谢代码示例!!
代码
this.beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.setForegroundScanPeriod(500);
beaconManager.setForegroundBetweenScanPeriod(500);
enableBackgroundMode(true);
beaconManager.setAndroidLScanningDisabled(true);
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_UID_LAYOUT));
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_URL_LAYOUT));
this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(EDDYSTONE_TLM_LAYOUT));
this.beaconManager.setDebug(true);
this.beaconManager.bind(this);
this.beaconManager.addRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
Log.e(TAG, "beacons size=>" + beacons.size());
if (beacons.size() > 0) {
//my code
}
}
});
LogCat:
10-12 12:33:48.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:49.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:50.356 12357-12881/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@26eeaf3b
10-12 12:33:50.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:51.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:52.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:52.391 12357-12880/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@26eeaf3b
10-12 12:33:53.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:54.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:54.396 12357-12880/com.mypackageName.android D/RangeState: adding id1: 87f8acb5-9ad0-29a7-204c-f080e2b55c0d id2: 10 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@26eeaf3b
10-12 12:33:55.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:56.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:57.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:58.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:33:59.381 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:34:00.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:34:01.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
10-12 12:34:02.376 12357-12357/com.mypackageName.android D/Callback: attempting callback via global broadcast intent: ComponentInfo{com.mypackageName.android/org.altbeacon.beacon.BeaconIntentProcessor}
尝试删除以下行:
beaconManager.setForegroundScanPeriod(500);
beaconManager.setForegroundBetweenScanPeriod(500);
如果没有这些行(使用默认设置),库将在前台不断扫描。有了这些线,它一次只会扫描半秒,这很可能会错过您的信标的传输并导致检测丢失。