0
votes

If I need to monitor a specific region of the UUID.

Declaring in a region, but when entering didEnterRegion, I only get UUID and Major and Minor as null, would I need to do didRangeBeaconsInRegion to find just the defined region without finding another unwanted region?

I define the region as follows:

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

Another question, does the library find beacons by location?

Thank you very much, Regards

public void onBeaconServiceConnect() {

    beaconManager.addMonitorNotifier(new MonitorNotifier() {
    @Override
    public void didEnterRegion(Region region) {
        Log.i(TAG, " enter region");
        try {
            beaconManager.startRangingBeaconsInRegion(region);
            Log.i(TAG, "region beacon" + region.getId1() + " " + region.getId2() + " " + region.getId3());
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void didExitRegion(Region region) {
        Log.i(TAG, "I no longer see an beacon");
        try {
            beaconManager.stopRangingBeaconsInRegion(region);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void didDetermineStateForRegion(int state, Region region) {
        Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+ state);
    }

});

try {
      beaconManager.startMonitoringBeaconsInRegion(new 
Region("myMonitoringUniqueId", Identifier.parse("UUID"), null, null));
    } catch (RemoteException e) {

   }
}
1

1 Answers

0
votes

The didEnterRegion callback does not tell you which specific beacon matched your Region definition. It returns a copy of the Region object you used when you called startMonitoringBeaconsInRegion. If you want do get the specific identifiers of matched beacons, use startRangingBeaconsInRegion(...) and wait for a callback to didRangeBeaconsInRegion(...), which will include a list of all matched beacons.

There are many reasons the API works this way, but the most fundamental is because the API is modeled after the equivalent CoreLocation APIs on iOS for interoperability, and they work the same way.