Java 如何为每次检测生成所有iBeacon信息?
我在实验环境中部署了9个iBeacon。通过以下方式检测区域iBeacons:Java 如何为每次检测生成所有iBeacon信息?,java,android,beacon,altbeacon,Java,Android,Beacon,Altbeacon,我在实验环境中部署了9个iBeacon。通过以下方式检测区域iBeacons: public void onBeaconServiceConnect() { beaconManager.setRangeNotifier(new RangeNotifier() { @Override public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
System.out.println("The number of iBeacons detected = "+beacons.size());
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) {
}
}
我确认每个iBeacon都正常运行。
如何为每次检测生成所有iBeacon信息?我怀疑您的信标的广告频率不足以进行可靠的检测 每个信标制造商都有一个不同的默认广告费率——发送数据包的频率。iBeacon标准要求10 Hz(每秒10包),但许多电池供电信标制造商将其降低到1 Hz(每秒1包)以节省电池 问题在于,即使在最佳条件下,也没有100%的数据包被检测到,这也是苹果公司规定传输速率为每秒一次的正常测距速率的10倍以确保检测可靠的原因之一 要解决此问题,请执行以下两项操作之一:
beaconManager.setForegroundScanPeriod(10000)代码>
非常感谢。我会再试一次。关于第二点:其中
beaconManager.setForegroundScanPeriod(10000)代码>是否应添加?首次使用BeaconManagerRafter添加beaconManager.setForegroundScanPeriod(5000)时添加它代码>我能做到。非常感谢。
I/System.out: The number of iBeacons detected = 2
I/System.out: The number of iBeacons detected = 4
I/System.out: The number of iBeacons detected = 8
I/System.out: The number of iBeacons detected = 7
I/System.out: The number of iBeacons detected = 9
I/System.out: The number of iBeacons detected = 4
I/System.out: The number of iBeacons detected = 4
I/System.out: The number of iBeacons detected = 5
I/System.out: The number of iBeacons detected = 6
I/System.out: The number of iBeacons detected = 3
I/System.out: The number of iBeacons detected = 6
I/System.out: The number of iBeacons detected = 2
I/System.out: The number of iBeacons detected = 7
I/System.out: The number of iBeacons detected = 7