android - 使用 Altbeacon 库监控 iBeacon

标签 android ibeacon altbeacon

我正在测试来自 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/

相关文章:

android - 在android中处理按钮上的多个点击事件

android - 处理数据流并在后台创建记录

android - 我只想在设备位于地理围栏区域时启用打卡按钮。我需要做什么?

android - android中手势是如何存储的

ios - 面向 iBeacon 的设备方向

ios - 无法检测 iBeacon 蓝牙何时关闭 iOS

Swift Beacon 现在不能使用 Swift 3.0

ios - iOS 下 altBeacons 上的 Major 和 Minor

android - OnyxBeacons 的 AltBeacon 不稳定,循环通过 didEnterRegion 和 didExitRegion 重复

java - Altbeacon - 扫描数组中的多个 UUID