我正在测试来自 AltBeacon 的 Android Beacon 库 http://altbeacon.github.io/android-beacon-library/index.html
我正在监视一个“通用”区域,仅设置第一个 ID (UUID),并将 id2 和 id3 保留为空。
Region region = new Region(uuid, Identifier.parse(uuid), null, null);
我收到 didEnterRegion 没有问题,但我有一个问题。 在 didEnterRegion 中,我收到了 Region 作为参数,但我能知道启动事件的具体信标吗?我想知道启动此事件区域的信标的 id1、id2 和 id3,这可能吗?
提前致谢
最佳答案
如果您需要知道检测到的特定信标的标识符,只需使用测距 API。您将获得一个包含标识符的 Beacon 对象的回调:
beaconManager.setRangeNotifier(this);
beaconManager.startRangingBeaconsInRegion(region);
...
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
for (Beacon beacon: beacons) {
Log.i(TAG, "Beacon detected with id1: "+beacon.getId1()+" id2:"+beacon.getId2()+" id3: "+beacon.getId3());
}
}
关于android - 使用 Altbeacon 库监控 iBeacon,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25443814/