Looping on beacons

前端 未结 1 1508
温柔的废话
温柔的废话 2021-01-28 14:56
@Override
public void onBeaconServiceConnect() {
    BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
    beaconManager.setRangeNotifier(new          


        
1条回答
  •  执念已碎
    2021-01-28 15:38

    I often use a BeaconTracker singleton class in apps where I want to keep track of the last distance seen to each beacon. You can see an example of this here:

    https://github.com/davidgyoung/ningo-android/blob/master/app/src/main/java/com/davidgyoungtech/beaconscanner/BeaconTracker.java

    You can use this class by calling it from your didRangeBeaconsInRegion(...) callback like this:

    BeaconTracker.getInstance(context).updateTrackedBeacons(beacons);
    

    You can then access the tracked beacons later to compare distance with:

    List trackedBeacons = BeaconTracker.getInstance(context).getTrackedBeacons();
    

    0 讨论(0)
提交回复
热议问题