Hello,
In my app I’m making I implemented a service which will first monitor for a certain beacon, when I enter the region of that beacon I start ranging. It’s actually just an app to open a door when I get near the beacon. My problem is that when I range for beacon and I call Util.computeAccuracy() 3 to 6 values I get back are exactly the same. This means that for 3 to 6 sec my distance to the beacon doesn’t change. Anyone had same kind of problem or anyone knows a fix for this? Maybe it’s something I do wrong in my code?
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
// The counter is an extra safety, the first time we go from ranging to
// monitoring, it takes a while before our beacon is in the list that is passed
// as a parameter to this method. To avoid clipping from ranging to monitoring,
// we say that we have to wait 5 times before going back to monitoring.
counter++;
if (!list.isEmpty()) {
counter = 0;
Beacon nearestBeacon = list.get(0);
Log.d(DEBUGTAG, "Distance to beacon: " + Utils.computeAccuracy(nearestBeacon));
if (Utils.computeProximity(nearestBeacon) == Utils.Proximity.IMMEDIATE) {
// TODO Replace .IMMEDIATE with .NEAR
doRequest();
}
} else if (counter > 10) {
// This means the door beacon is again out of range
counter = 0;
rangingToMonitoring();
}
}
Thanks in advance!
Debug console:
Distance to beacon: 5.670535458084814
Distance to beacon: 1.5618129043684257
Distance to beacon: 1.5618129043684257
Distance to beacon: 1.5618129043684257
Distance to beacon: 1.5618129043684257
Distance to beacon: 1.5618129043684257
Distance to beacon: 1.5618129043684257
Distance to beacon: 1.5618129043684257
Distance to beacon: 1.4231323591700062
Distance to beacon: 1.4231323591700062
Distance to beacon: 1.4231323591700062
Distance to beacon: 1.4231323591700062
Distance to beacon: 1.4231323591700062
Distance to beacon: 1.4231323591700062
Distance to beacon: 1.4231323591700062
Distance to beacon: 1.9791775637802211
Distance to beacon: 1.9791775637802211
Distance to beacon: 1.9791775637802211