5

我正在测试来自 AltBeacon http://altbeacon.github.io/android-beacon-library/index.html的 Android Beacon 库

我正在监视一个“通用”区域,仅设置第一个 id (UUID),并将 id2 和 id3 设为空。

Region region = new Region(uuid, Identifier.parse(uuid), null, null);

我收到 didEnterRegion 没有问题,但我有一个问题。在 didEnterRegion 我收到 Region 作为参数,但我能知道启动事件的具体信标吗?我想知道启动这个事件区域的beacon的id1、id2和id3,这可能吗?

提前致谢

4

1 回答 1

9

如果您需要知道您检测到的特定信标的标识符,只需使用测距 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());     
        }
}
于 2014-08-22T10:47:20.827 回答