I'm also having trouble getting startMonitoringBeacons to trigger didEnterRegion, while startRangingBeacons works fine.
Issue Summary:
startMonitoringBeacons does not trigger didEnterRegion when using a wildcard region (new Region("wildcardRegion", null, null, null)). However, if I specify a UUID, Major, and Minor (specifiedRegion), the callback does trigger correctly. startRangingBeacons works fine and continuously detects beacons, so permissions and configuration seem correct.
Code Snippet:
BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
// Define beacon format (iBeacon)
beaconManager.getBeaconParsers().clear();
beaconManager.getBeaconParsers().add(new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
// Ranging works fine
beaconManager.addRangeNotifier((beacons, region) -> {
if (!beacons.isEmpty()) {
for (Beacon beacon : beacons) {
Log.d(TAG, "Ranged Beacon: " + beacon.getId1());
}
}
});
beaconManager.startRangingBeacons(wildcardRegion);
// Monitoring (Not Working for wildcardRegion)
beaconManager.addMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.d(TAG, "Entered Region: " + region.getUniqueId());
}
@Override
public void didExitRegion(Region region) {
Log.d(TAG, "Exited Region");
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.d(TAG, "Region State Changed: " + state);
}
});
// Not Working
Region wildcardRegion = new Region("wildcardRegion", null, null, null);
beaconManager.startMonitoring(wildcardRegion);
// Working
Region specifiedRegion = new Region("specifiedRegion",
Identifier.parse("fda50693a4e24fb1afcfc6eb07647825"),
Identifier.parse("1"), Identifier.parse("2"));
beaconManager.startMonitoring(specifiedRegion);
Environment Information:
Library: AltBeacon 2.19
Android Version: 9
Device: Google Pixel 6
Permissions: ACCESS_FINE_LOCATION, BLUETOOTH, FOREGROUND_SERVICE (granted)
Background Scanning: Enabled
Questions:
1. Does wildcard region monitoring (new Region("wildcardRegion", null, null, null)) work as expected in the latest AltBeacon version?
2. Are there specific configurations required for monitoring wildcard regions?
3. Any debugging tips to find out why didEnterRegion is not triggering for wildcard regions while specific regions work fine?