4
votes

I am testing the Android Beacon Library from AltBeacon http://altbeacon.github.io/android-beacon-library/index.html

I am monitoring one "generic" region setting only the first id (UUID), and levaing id2, and id3 as null.

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

I receive the didEnterRegion without problems, but i have a question. In didEnterRegion i receive the Region as a parameter, but can i know the concrete beacon that launched the event? I want to know the id1, id2, and id3 of the beacon that launches this event region, is this possible?

Thanks in advance

1

1 Answers

8
votes

If you need to know the identifiers of the specific beacons you detected, simply use the ranging APIs. You will get a callback with a Beacon object that contains the identifiers:

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());     
        }
}