Hello,
I am working on Android app. In this, Firstly i want nearest beacon for that i am using ranging. It works nicely. After that i am starting monitoring of this nearest beacon. But problem is that i didn’t receive any entry/exit in monitoring listener for that nearest beacon.
Any help would be much appreciated.
Best Regards,
Monik.
Hello,
I noticed that monitoring listener called entry event but it’s taking too much time more then 5 - 10 mins.
Any suggestion would be much appreciated.
Thank you,
Monik.
Hmm, so you go in range of your beacon, but you only get the “onEntered” event after 5–10 minutes?
Can you share your code?
Thank you for reply.
Here is my code.
boolean isMonitoringStart = false;
BeaconManager beaconManager = new BeaconManager(getApplicationContext());
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
if (!list.isEmpty()) {
Beacon nearestBeacon = list.get(0);
final int newRangingMajor = nearestBeacon.getMajor();
final int newRangingMinor = nearestBeacon.getMinor();
if (!isMonitoringStart) {
isMonitoringStart = true;
beaconManager.startMonitoring(new Region(
"monitored region",
UUID.fromString("A06C035F-9F5A-FA60-0117-C0569FAC2941"),
newRangingMajor, newRangingMinor));
}
}
}
});
regionStartStop = new Region("ranged region", UUID.fromString("A06C035F-9F5A-FA60-0117-C0569FAC2941"), null, null);
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
beaconManager.startMonitoring(new Region("monitored region",UUID.fromString("A06C035F-9F5A-FA60-0117-C0569FAC2941"), null, null));
}
});
beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> list) {
if (region.getMajor() != null) {
// I Want Major & Minor Here...
String regionMajor = region.getMajor().toString();
String regionMinor = region.getMinor().toString();
} else {
if (isRegionOn == false) {
isRegionOn = true;
beaconManager.stopMonitoring(
new Region("monitored region", UUID.fromString("A06C035F-9F5A-FA60-0117-C0569FAC2941"), null, null));
// Start Ranging Here...
beaconManager.startRanging(regionStartStop);
}
}
}
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onExitedRegion(Region region) {
if (region.getMajor() != null) {
// I Want Major & Minor Here...
}
}
});
I started monitoring of particular beacon with major & minor in ranging listener. And i want entry/exit of that beacon but i didn't get any entry.
I checked it.
It works sometime(got entry/exit) in XOLO(Android V - 5.1)
But, It didn't work in Nexus 6(Android V - 6.0.1)