Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring iBeacons with Altbeacon library

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

like image 780
OverMind Avatar asked Aug 22 '14 09:08

OverMind


1 Answers

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());     
        }
}
like image 89
davidgyoung Avatar answered Oct 22 '22 08:10

davidgyoung