如果我需要监视UUID的特定区域。
在一个区域中声明,但是当输入didEnterRegion时,我只将UUID和主要和次要作为null,我是否需要执行didRangeBeaconsInRegion才能仅找到定义的区域而不找到另一个不需要的区域?
我按如下方式定义区域:
Region region = new Region ("region", Identifier.parse ("UUID"), null, null);
另一个问题, 图书馆是否按位置找到信标?
谢谢 问候
public void onBeaconServiceConnect() {
beaconManager.addMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, " enter region");
try {
beaconManager.startRangingBeaconsInRegion(region);
Log.i(TAG, "region beacon" + region.getId1() + " " + region.getId2() + " " + region.getId3());
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an beacon");
try {
beaconManager.stopRangingBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+ state);
}
});
try {
beaconManager.startMonitoringBeaconsInRegion(new
Region("myMonitoringUniqueId", Identifier.parse("UUID"), null, null));
} catch (RemoteException e) {
}
}
didEnterRegion
回调不会告诉您哪个特定信标与您的区域定义匹配。 它返回调用startMonitoringBeaconsInRegion
时使用的Region
对象的副本。 如果您想获取匹配信标的特定标识符, 使用startRangingBeaconsInRegion(...)
并等待回调didRangeBeaconsInRegion(...)
, 这将包括所有匹配信标的列表.
API以这种方式工作的原因有很多,但最根本的是,API 是根据 iOS 上等效的 CoreLocation API 建模的,以实现互操作性,并且它们的工作方式相同。