private double findNearestBeacon(List<Beacon> list)
{
Beacon nearestBeacon = null;
double nearestBeaconsDistance = -1;
for (Beacon beacon : list) {
double distance = Utils.computeAccuracy(beacon);
if (distance > -1 &&
(distance < nearestBeaconsDistance || nearestBeacon == null)) {
nearestBeacon = beacon;
nearestBeaconsDistance = distance;
}
}
return nearestBeaconsDistance;
}
I have this function to compute the lowest value of distance in beacons, I’m fairly new in java so before I try to do this, I would like to know if this is possible to achieve.
I’m trying to create a listview, where beacons and the distance to each beacon are listed respectively.