use of com.google.android.gms.location.LocationResult in project coursera-android by aporter.
the class LocationGetLocationActivity method getLocationCallback.
@NonNull
private LocationCallback getLocationCallback() {
return new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
ensureColor();
// Get new location
Location location = locationResult.getLastLocation();
// Determine whether new location is better than current best estimate
if (null == mBestReading || location.getAccuracy() < mBestReading.getAccuracy()) {
// Update best location
mBestReading = location;
// Update display
updateDisplay(location);
// Turn off location updates if location reading is sufficiently accurate
if (mBestReading.getAccuracy() < MIN_ACCURACY) {
mLocationClient.removeLocationUpdates(mLocationCallback);
}
}
}
};
}
Aggregations