【问题标题】:Monitoring iBeacons with Altbeacon library使用 Altbeacon 库监控 iBeacon
【发布时间】:2014-08-22 09:31:48
【问题描述】:

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

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

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

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

提前致谢

【问题讨论】:

    标签: android ibeacon altbeacon


    【解决方案1】:

    如果您需要知道您检测到的特定信标的标识符,只需使用测距 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());     
            }
    }
    

    【讨论】:

    • 感谢您的回复,但我不想在每次监控时都进行测距。我想如果我这样做,我会耗尽电池
    • 好消息!您无需担心测距时使用额外的电池。无论您是否进行测距,都会进行相同的无线电扫描,因此测距是读取信标标识符的正确方法。电池问题不在于监控与测距,而在于扫描频率。默认情况下,当您的应用程序处于前台时,该库会不断扫描,而当您的应用程序处于后台时,该库会每五分钟扫描一次。详情见这里:altbeacon.github.io/android-beacon-library/battery_manager.html
    • 正如电池管理器文章所说,自 Android 8 及更高版本以来,这有一些限制。文章中还提到了替代方案,为了更快地访问,我在这里复制它:altbeacon.github.io/android-beacon-library/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    相关资源
    最近更新 更多