Ove*_*ind 4 android ibeacon altbeacon
我正在测试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);
Run Code Online (Sandbox Code Playgroud)
我收到了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());
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3770 次 |
| 最近记录: |