This is my code so far: This method goes through the list of beacon objects I have saved in my DB, and create a region for every beacon in the list:
for (nl.hgrams.passenger.model.vehicle.Beacon beacon : beacons) {
if (beacon.getUser_vehicle() != null) {
Utils.appendLog("Added a beacon region for: " + beacon.getName(), "I", Constants.TRACKER);
Region region = new Region("all-beacons-region", Identifier.parse(beacon.getUuid()), null, null);
regions.add(region);
}
}
Then I go through the list, and call startMonitoringBeaconsInRegion(region):
try {
for (Region region : regions) {
beaconManager.startMonitoringBeaconsInRegion(region);
}
} catch (RemoteException e) {
Log.e("", "region error trying to start ranging beacons in region");
e.printStackTrace();
}
But what I noticed is that it will listen only to the last Region it monitored. Why doesn't it listen to all of them? How can I make it listen to all regions? Is it possible to pass more uuids to a region or something like that , that will fix this?
I tried using this:
PSApplicationClass.getInstance().regionBootstrap = new RegionBootstrap(bootstrapNotifier, regions);
With the RegionBootstrap with my Application class implementing the boostrapNotifier. Using it with the regions list created with the code of the for Loop I have before the EDIT. But I get EnteredRegion called once, and then I get no more EXIT, or ENTERED events, why?
The issue was here:
Region region = new Region("all-beacons-region", Identifier.parse(beacon.getUuid()), null, null);
I was setting the first arg. for all regions as: all-beacons-region
which would case them to be overriden. Hence why only the last was being called