Favolas
Favolas

Reputation: 7243

AltBeacon Android Beacon Library region id is null

I'm using AltBeacon android library to detect Eddystone beacons on my app.

I'm setting the region like this:

Region region = new Region("backgroundRegion", null, null, null);

Whenever my app detects a beacon in range, I'm logging it like this:

@Override public void didEnterRegion(Region region) {
        Log.v(TAG, "didEnterRegion() called with: region = [" + region.toString() + "]");
    }

id1, id2 and id3 return null.

Instead, if I do this:

Region region = new Region("backgroundRegion", Identifier.parse("0x0b85497366bad1356d69"), null, null);

id1 returns `b85497366bad1356d69``

I want to detect all Eddystone devices. Can I get the device identifier if I do not set the region for that identifier?

Upvotes: 0

Views: 518

Answers (1)

davidgyoung
davidgyoung

Reputation: 64995

The Ranging object in the callback for didEnterRegion is simply a copy of the one you used to start monitoring, so the identifiers will be all null if the initial Region has identifiers all null.

The solution? Use startRangingBeaconsInRegion() and the didRangeBeaconsInRegion callback. That callback will give you a list of detected beacons matching the region, so you can read all the actual identifiers.

Upvotes: 1

Related Questions