All beacons are not shown in Android using altBeacon library

后端 未结 2 1712
后悔当初
后悔当初 2021-01-06 04:56

I am using the AltBEacon Android library for developing an iBeacon app for Android devices. I am scanning for beacons, however, only two out of four

2条回答
  •  情深已故
    2021-01-06 05:21

    OK, I finally solved it. I ordered according to the beacon MAC address. So instead of:

    public void initAll(Collection newBeacons) {
        this.beacons.clear();
        this.beacons.addAll(newBeacons);
    }
    

    I did:

    public void initAll(Collection newBeacons) {
    
        this.beacons.clear();
        this.beacons.addAll(newBeacons);
    
        //Sort
        Collections.sort(this.beacons, new Comparator() {
            @Override
            public int compare(Beacon b1, Beacon b2) {
                String mac1 = b1.getBluetoothAddress();
                String mac2 = b2.getBluetoothAddress();
    
                return mac1.compareTo(mac2);
            }
        });
    }
    

提交回复
热议问题