I am using Android Beacon Library to make a beacon detector application. I want to detect Eddystone UID's which start with 007B. I am using
mRegionSuccess = new Region("BeaconsSuccess", Identifier.parse("0x007b", 2), null, null);
This doesn't detect beacons which start with 007b.
When I log the region, it gives id1: 123 id2: null id3: null
This 123 is the byte value of 7B.
I tried Identifier.parse function with the complete 10 byte namespace and it was working. Here the region was id1: 0x007bxxxxxxxx id2: null id3: null
What can be the issue?
The API just does not work like that. It will not match partial identifiers, only whole identifiers. If you create a region with the first identifier of 0x007b, and try to match a beacon with first identifier of 0x007b0000000000000000, it will not match because 0x007b != 0x007b0000000000000000.
If you really want to match just the first two bytes of the first identifier, you can define a custom beacon format variant of Eddystone-UID that defines the first identifier as the first two bytes of the namespace. You can make the second two identifiers be the full namespace and instance identifiers, respectively. Like this:
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("s:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-5,i:4-13,i:14-19"));
It's a bit of a hack, but this will allow you to do what you want.