我使用altbeacon库2.15+但奥利奥和牛轧糖的版本不扫描灯塔?

问题描述 投票:0回答:1

onBeacon ServiceConnect方法是检测信标。用于棒棒糖版本检测用于牛轧糖和奥利奥版本信标未检测的:public void onBeaconServiceConnect(){

    RangeNotifier rangeNotifier = new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, org.altbeacon.beacon.Region region) {
            Log.d(TAG, "in didRangeBeaconsInRegion " + beacons.size());
            if (beacons.size() > 0) {
                Log.d(TAG, "didRangeBeaconsInRegion called with beacon count:  " + beacons.size());
                for (Iterator<Beacon> iterator = beacons.iterator();
                     iterator.hasNext(); ) {
                    Beacon beacon = iterator.next();

                    if (beaconlist.size() > 0) {
                        Log.d(TAG, "List Size :" + beaconlist.size());
                        for (int i = 0; i < beaconlist.size(); i++) {
                            Log.d("BeaconList ", beaconlist.get(i));
                        }
                    }

                    if (!beaconlist.contains(beacon.getId1().toString())) {
                        Log.d(TAG,"In get APi");
                        getApi(beacon.getId1().toString());
                        beaconlist.add(beacon.getId1().toString());
                        Log.d(TAG, "Notify in dead state");
                        Log.d("Notify in dead state", beacon.getId1().toString());
                    }
                }
            }
        }
    };
    try {
        Log.d(TAG, "I am in startRangingBeaconsInRegion");
        beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
        beaconManager.addRangeNotifier(rangeNotifier);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}

这是我的代码可以在任何一个给了这个问题的解决方案。

ibeacon beacon altbeacon ibeacon-android android-ibeacon
1个回答
1
投票

有两件事情要检查:

  1. 您已经添加COARSE_LOCATION权限到AndroidManifest.xml并添加代码,以成功地获得在运行时动态用户的许可?
  2. 你成功地构建一个BeaconManager,调用bind(......),并验证你的回调范围开始之前,onBeaconServiceConnect()?如果不这样做,你会当您尝试启动范围得到一个RemoteException。这是登录此异常与Log.e(TAG, "Not bound to beacon scanning service")到logcat的一个好主意
© www.soinside.com 2019 - 2024. All rights reserved.