2
votes

I'm developing an app which provides background Beacon monitoring. I would like to start ranging when user enters beacon from defined region. Unfortunately I can't define region for Eddystone profile. When I create region object with Eddystone NamespaceID the Identifier throws parsing exception...

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

When Identifier is in UUID format or integer according to docs (https://altbeacon.github.io/android-beacon-library/javadoc/org/altbeacon/beacon/Identifier.html) parsing works fine. So, when Beacon is set to Eddystone, NamespaceID is first Identifier which should define region exactly the same as UUID is first Identifier in iBeacon profile. Do I understand it right? If I'm right in that situation I can't parse Eddystone NamespaceID as Identifier for region and can't monitor if user enter beacons which are set to use Eddystone profile. Please correct me if I'm wrong and please tell me how to define region for Eddystone beacons.

Thanks!

1

1 Answers

2
votes

You can define a Region that matches an Eddystone-UID namespaceID like this:

Region region = new Region("my-beacon-region", Identifier.parse("0xf7826da6bc5b71e0893e"), null, null);

The trick is to prefix the identifier with "0x" to indicate to the library that the identifier is a multi-byte hex value. For convenience, a prefix is not needed when parsing identifiers from UUIDs or integer values, but one is needed for multi-byte hex values otherwise there would be no way to differentiate between "0x1000" (4096 decimal) and "1000" (1000 decimal).

See more details on working with Eddystone-UID with the Android Beacon Library here:

http://altbeacon.github.io/android-beacon-library/eddystone-how-to.html