beaconManager.setMonitoringListener is working but beaconManager.setRangingListener not working.
Can you help me?
Thanks
It was coded as follows:
Region region;
BeaconManager beaconManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
beaconManager = new BeaconManager(this);
region = new Region("ranged region", UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), null, null);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
Log.d("myLog", "onBeaconsDiscovered " + "onBeaconsDiscovered !!'");
if (!list.isEmpty()) {
Beacon nearestBeacon = list.get(0);
}
}
});
}
@Override
protected void onStart() {
super.onStart();
SystemRequirementsChecker.checkWithDefaultDialogs(this);
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
try {
beaconManager.startRanging(region);
} catch (Exception e) {
Log.d("myLog", "Errore scansione Beacon : " + e.getMessage());
}
}
});
}
@Override
protected void onStop() {
beaconManager.stopRanging(region);
super.onStop();
}