【问题标题】:Altbeacon scanner specific UUID in AndroidAndroid中的Altbeacon扫描仪特定UUID
【发布时间】:2019-08-15 15:46:32
【问题描述】:

如果我需要监控 UUID 的特定区域。

在一个区域中声明,但是当进入 didEnterRegion 时,我只得到 UUID 和 Major 和 Minor 为空,我是否需要做 didRangeBeaconsInRegion 来只找到定义的区域而不找到另一个不需要的区域?

我将区域定义如下:

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

另一个问题,图书馆是否按位置查找信标?

非常感谢, 问候

public void onBeaconServiceConnect() {

    beaconManager.addMonitorNotifier(new MonitorNotifier() {
    @Override
    public void didEnterRegion(Region region) {
        Log.i(TAG, " enter region");
        try {
            beaconManager.startRangingBeaconsInRegion(region);
            Log.i(TAG, "region beacon" + region.getId1() + " " + region.getId2() + " " + region.getId3());
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void didExitRegion(Region region) {
        Log.i(TAG, "I no longer see an beacon");
        try {
            beaconManager.stopRangingBeaconsInRegion(region);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void didDetermineStateForRegion(int state, Region region) {
        Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+ state);
    }

});

try {
      beaconManager.startMonitoringBeaconsInRegion(new 
Region("myMonitoringUniqueId", Identifier.parse("UUID"), null, null));
    } catch (RemoteException e) {

   }
}

【问题讨论】:

    标签: android android-studio ibeacon beacon altbeacon


    【解决方案1】:

    didEnterRegion 回调不会告诉您哪个特定信标与您的区域定义匹配。它返回您在调用startMonitoringBeaconsInRegion 时使用的Region 对象的副本。如果您想获取匹配信标的特定标识符,请使用startRangingBeaconsInRegion(...) 并等待回调到didRangeBeaconsInRegion(...),其中将包含所有匹配信标的列表。

    API 以这种方式工作的原因有很多,但最根本的原因是该 API 模仿 iOS 上等效的 CoreLocation API 以实现互操作性,并且它们的工作方式相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      相关资源
      最近更新 更多