private String computeNearbyLocation(LocationPoint measurementPt) { Double dist = 999.99; String nearbyLoc = "Cannot be localized!"; String strToast = ""; for (LocationPoint ref : references) { Double d = ref.distanceFrom(measurementPt); if (Double.compare(d, dist) <= 0) { dist = d; nearbyLoc = ref.name + " (Dist: " + String.format("%.2f", d) + ")"; } strToast = strToast + ref.name + " (Dist: " + String.format("%.2f", d) + ")" + "\n"; } Toast.makeText(LocalizationActivity.this, strToast, Toast.LENGTH_SHORT).show(); return nearbyLoc; }