com.google.android.gms.location.LocationResult Java Examples

The following examples show how to use com.google.android.gms.location.LocationResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNFusedLocationModule.java    From react-native-geolocation-service with MIT License 7 votes vote down vote up
/**
 * Get periodic location updates based on the current location request.
 */
private void getLocationUpdates() {
  if (mFusedProviderClient != null && mLocationRequest != null) {
    mLocationCallback = new LocationCallback() {
      @Override
      public void onLocationAvailability(LocationAvailability locationAvailability) {
        if (!locationAvailability.isLocationAvailable()) {
          invokeError(
            LocationError.POSITION_UNAVAILABLE.getValue(),
            "Unable to retrieve location",
            false
          );
        }
      }

      @Override
      public void onLocationResult(LocationResult locationResult) {
        Location location = locationResult.getLastLocation();
        invokeSuccess(LocationUtils.locationToMap(location), false);
      }
    };

    mFusedProviderClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
  }
}
 
Example #2
Source File: LocationUpdateReceiver.java    From home-assistant-Android with GNU General Public License v3.0 7 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    prefs = Utils.getPrefs(context);
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
        case ACTION_START_LOCATION:
            apiClient = new GoogleApiClient.Builder(context)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(LocationServices.API)
                    .build();

            apiClient.connect();
            break;
        case ACTION_LOCATION_UPDATE:
            if (prefs.getBoolean(Common.PREF_ENABLE_LOCATION_TRACKING, false) && LocationResult.hasResult(intent)) {
                LocationResult result = LocationResult.extractResult(intent);
                Location location = result.getLastLocation();
                if (location != null)
                    logLocation(location, context);
            }
            break;
    }
}
 
Example #3
Source File: EasyWayLocation.java    From EasyWayLocation with Apache License 2.0 6 votes vote down vote up
/**
 * Starts updating the location and requesting new updates after the defined interval
 */
@SuppressLint("MissingPermission")
private void beginUpdates() {
    locationCallback = new LocationCallback(){
        @Override
        public void onLocationResult(LocationResult locationResult) {
            if (locationResult == null) {
                mListener.locationCancelled();
            }else {
                for (Location location : locationResult.getLocations()) {
                    mListener.currentLocation(location);
                }
            }

        }
    };

    fusedLocationClient.requestLocationUpdates(locationRequest,
            locationCallback,
            Looper.getMainLooper());
}
 
Example #4
Source File: WearableMainActivity.java    From wear-os-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    if (locationResult == null) {
        return;
    }


    for (Location location : locationResult.getLocations()) {
        Log.d(TAG, "onLocationChanged() : " + location);


        if (mWaitingForGpsSignal) {
            mWaitingForGpsSignal = false;
            updateActivityViewsBasedOnLocationPermissions();
        }

        mSpeed = location.getSpeed() * MPH_IN_METERS_PER_SECOND;
        updateSpeedInViews();
        addLocationEntry(location.getLatitude(), location.getLongitude());
    }
}
 
Example #5
Source File: LocationUpdatesBroadcastReceiver.java    From background_location_updates with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_LOCATION_UPDATE.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                LocationEntity[] locationEntities = new LocationEntity[locations.size()];
                for (int i = 0; i < locations.size(); i++) {
                    locationEntities[i] = LocationEntity.fromAndroidLocation(locations.get(i));
                }
                new TraceInserter(context).execute(locationEntities);
            }
        }
    }
}
 
Example #6
Source File: FusedLocationIntentService.java    From android-notification-log with MIT License 6 votes vote down vote up
@Override
protected void onHandleIntent(@Nullable Intent intent) {
	if(LocationResult.hasResult(intent)) {
		LocationResult locationResult = LocationResult.extractResult(intent);
		Location location = locationResult.getLastLocation();

		JSONObject json = new JSONObject();
		String str = null;
		try {
			long now = System.currentTimeMillis();
			json.put("time", now);
			json.put("offset", TimeZone.getDefault().getOffset(now));
			json.put("age", now - location.getTime());
			json.put("longitude", location.getLongitude() + "");
			json.put("latitude", location.getLatitude() + "");
			json.put("accuracy", location.getAccuracy());
			str = json.toString();
		} catch (JSONException e) {
			if(Const.DEBUG) e.printStackTrace();
		}

		SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
		sp.edit().putString(Const.PREF_LAST_LOCATION, str).apply();
	}
}
 
Example #7
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
  Location location = locationResult.getLastLocation();
  if (location != null) {
    updateTextView(location);
  }
}
 
Example #8
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
  Location location = locationResult.getLastLocation();
  if (location != null) {
    updateTextView(location);
  }

  if (location != null) {
    updateTextView(location);
    if (mMap != null) {
      LatLng latLng = new LatLng(location.getLatitude(),
        location.getLongitude());
      mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
    }
  }
}
 
Example #9
Source File: CustomLocationTrackingActivity.java    From android-map-sdk with Apache License 2.0 6 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    if (map == null) {
        return;
    }
    Location lastLocation = locationResult.getLastLocation();
    LatLng coord = new LatLng(lastLocation);
    LocationOverlay locationOverlay = map.getLocationOverlay();
    locationOverlay.setPosition(coord);
    locationOverlay.setBearing(lastLocation.getBearing());
    map.moveCamera(CameraUpdate.scrollTo(coord));
    if (waiting) {
        waiting = false;
        fab.setImageResource(R.drawable.ic_location_disabled_black_24dp);
        locationOverlay.setVisible(true);
    }
}
 
Example #10
Source File: GoogleLocationEngineImplAdditionalTest.java    From mapbox-events-android with MIT License 6 votes vote down vote up
@Before
public void setUp() {
  location = mock(Location.class);
  when(location.getLatitude()).thenReturn(1.0);
  when(location.getLongitude()).thenReturn(2.0);
  locationList.clear();
  locationList.add(location);
  fusedLocationProviderClient = mock(FusedLocationProviderClient.class);
  mockTask = mock(Task.class);
  mockLocationTask = mock(Task.class);
  when(fusedLocationProviderClient.getLastLocation()).thenReturn(mockLocationTask);
  when(fusedLocationProviderClient
    .requestLocationUpdates(any(LocationRequest.class), any(LocationCallback.class), any(Looper.class)))
    .thenAnswer(new Answer<Task<Void>>() {
      @Override
      public Task<Void> answer(InvocationOnMock invocation) {
        LocationCallback listener = (LocationCallback) invocation.getArguments()[1];
        listener.onLocationResult(LocationResult.create(locationList));
        return mockTask;
      }
    });

  engine = new LocationEngineProxy<>(new GoogleLocationEngineImpl(fusedLocationProviderClient));
}
 
Example #11
Source File: LocationUpdatesBroadcastReceiver.java    From background-location-updates-android-o with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                LocationResultHelper locationResultHelper = new LocationResultHelper(
                        context, locations);
                // Save the location data to SharedPreferences.
                locationResultHelper.saveResults();
                // Show notification with the location data.
                locationResultHelper.showNotification();
                Log.i(TAG, LocationResultHelper.getSavedLocationResult(context));
            }
        }
    }
}
 
Example #12
Source File: LocationUpdatesIntentService.java    From background-location-updates-android-o with Apache License 2.0 6 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                LocationResultHelper locationResultHelper = new LocationResultHelper(this,
                        locations);
                // Save the location data to SharedPreferences.
                locationResultHelper.saveResults();
                // Show notification with the location data.
                locationResultHelper.showNotification();
                Log.i(TAG, LocationResultHelper.getSavedLocationResult(this));
            }
        }
    }
}
 
Example #13
Source File: BaseNiboFragment.java    From Nibo with MIT License 6 votes vote down vote up
/**
 * Creates a callback for receiving location events.
 */
private void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            Location location = locationResult.getLastLocation();
            if (location != null) {
                extractGeocode(location.getLatitude(), location.getLongitude());


                CameraPosition cameraPosition = new CameraPosition.Builder()
                        .target(new LatLng(location.getLatitude(), location.getLongitude()))
                        .zoom(15)
                        .build();
                mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
                handleLocationRetrieval(location);
                extractGeocode(location.getLatitude(), location.getLongitude());
            }
        }
    };
}
 
Example #14
Source File: SamLocationRequestService.java    From SamLocationAndGeocoding with MIT License 6 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    super.onLocationResult(locationResult);
    int temp = locationResult.getLocations().size();
    --temp;
    Log.e("Lat", " " + String.valueOf(locationResult.getLocations().get(temp).getLatitude()));
    Log.e("Long", " " + String.valueOf(locationResult.getLocations().get(temp).getLongitude()));
        stopLocationUpdates();
        LocationAddress locationAddress = new LocationAddress();

        geolocation = locationAddress.getAddressFromLocation(locationResult.getLocations().get(temp).getLatitude(),locationResult.getLocations().get(temp).getLongitude(),
                context);
        Log.e("geolocation", " " + geolocation);


    samLocationListener.onLocationUpdate(locationResult.getLocations().get(temp),geolocation);

}
 
Example #15
Source File: GetLocation.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static LocationCallback getLocationCallback() {
    return new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            if (locationResult == null) {
                return;
            }
            final Location thisLocation = locationResult.getLastLocation();
            UserError.Log.d(TAG, "Got location update callback!! " + thisLocation);
            if ((lastLocation == null)
                    || thisLocation.getAccuracy() < lastLocation.getAccuracy()
                    || ((thisLocation.getAccuracy() < SKIP_DISTANCE) && (thisLocation.distanceTo(lastLocation) > SKIP_DISTANCE))) {

                lastLocation = thisLocation;
                UserError.Log.d(TAG, "Got location UPDATED element: " + lastLocation);
                Inevitable.task("update-street-location", 6000, () -> lastAddress = getStreetLocation(lastLocation.getLatitude(), lastLocation.getLongitude()));
            }
        }
    };
}
 
Example #16
Source File: GetLocation.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static LocationCallback getLocationCallback() {
    return new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            if (locationResult == null) {
                return;
            }
            final Location thisLocation = locationResult.getLastLocation();
            UserError.Log.d(TAG, "Got location update callback!! " + thisLocation);
            if ((lastLocation == null)
                    || thisLocation.getAccuracy() < lastLocation.getAccuracy()
                    || ((thisLocation.getAccuracy() < SKIP_DISTANCE) && (thisLocation.distanceTo(lastLocation) > SKIP_DISTANCE))) {

                lastLocation = thisLocation;
                UserError.Log.d(TAG, "Got location UPDATED element: " + lastLocation);
                Inevitable.task("update-street-location", 6000, () -> lastAddress = getStreetLocation(lastLocation.getLatitude(), lastLocation.getLongitude()));
            }
        }
    };
}
 
Example #17
Source File: GeofenceReceiver.java    From android-sdk with MIT License 6 votes vote down vote up
private void handleLocationUpdate(Context context, Intent intent) {
    LocationResult result = LocationResult.extractResult(intent);
    LocationAvailability availability = LocationAvailability.extractLocationAvailability(intent);
    Intent service = SensorbergServiceIntents.getServiceIntentWithMessage(
            context, SensorbergServiceMessage.MSG_LOCATION_UPDATED);
    if (result != null) {
        Location location = result.getLastLocation();
        if (location != null) {
            service.putExtra(SensorbergServiceMessage.EXTRA_LOCATION, location);
        }
    }
    if (availability != null) {
        service.putExtra(SensorbergServiceMessage.EXTRA_LOCATION_AVAILABILITY,
                availability.isLocationAvailable());
    }
    if (result != null || availability != null) {
        context.startService(service);
    } else {
        Logger.log.geofenceError("Received invalid location update", null);
    }
}
 
Example #18
Source File: BasePlatformCreate.java    From indigenous-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initiate the location libraries and services.
 */
private void initLocationLibraries() {
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
    mSettingsClient = LocationServices.getSettingsClient(this);

    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            // location is received
            mCurrentLocation = locationResult.getLastLocation();
            updateLocationUI();
        }
    };

    mRequestingLocationUpdates = false;

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
    mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
    builder.addLocationRequest(mLocationRequest);
    mLocationSettingsRequest = builder.build();
}
 
Example #19
Source File: LocationBackgroundService.java    From rn-background-location with MIT License 6 votes vote down vote up
private LocationCallback createLocationRequestCallback() {
    return new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            if (locationResult == null) {
                return;
            }
            for (Location location : locationResult.getLocations()) {
                LocationCoordinates locationCoordinates = createCoordinates(location.getLatitude(), location.getLongitude());
                broadcastLocationReceived(locationCoordinates);
                mFusedLocationClient.removeLocationUpdates(mLocationCallback);
            }
        }
    };
}
 
Example #20
Source File: CoordinatesView.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void startRequestingLocation() {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(5000);
    locationRequest.setFastestInterval(1000);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    locationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            if (locationResult != null) {
                Double latitude = locationResult.getLocations().get(0).getLatitude();
                Double longitude = locationResult.getLocations().get(0).getLongitude();
                updateLocation(GeometryHelper.createPointGeometry(longitude, latitude));
                mFusedLocationClient.removeLocationUpdates(locationCallback);
            }
        }
    };

    if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions((ActivityGlobalAbstract) getContext(),
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                ACCESS_LOCATION_PERMISSION_REQUEST);
    } else
        mFusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, null);

}
 
Example #21
Source File: RunService.java    From SEAL-Demo with MIT License 5 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    List<Location> locationList = locationResult.getLocations();
    if (locationList.size() > 0) {
        if (currentLocation == null) {
            currentLocation = locationList.get(locationList.size() - 1);
        } else {
            mLastLocation = currentLocation;
            currentLocation = locationList.get(locationList.size() - 1);
            if (mLastLocation.distanceTo(currentLocation) > MIN_DISTANCE_UPDATE && currentLocation.getAccuracy() < MIN_ACCURACY_GPS)
                distance += mLastLocation.distanceTo(currentLocation) * KILOMETER_METER_CONVERSION_RATE; // return distance in meter and then it is converted in kilometers
        }
    }
}
 
Example #22
Source File: GoogleLocationEngineImpl.java    From mapbox-events-android with MIT License 5 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
  super.onLocationResult(locationResult);
  List<Location> locations = locationResult.getLocations();
  if (!locations.isEmpty()) {
    callback.onSuccess(LocationEngineResult.create(locations));
  } else {
    callback.onFailure(new Exception("Unavailable location"));
  }
}
 
Example #23
Source File: CalculationModulesArrayList.java    From GNSS_Compare with Apache License 2.0 5 votes vote down vote up
public CalculationModulesArrayList(){
    gnssCallback = new GnssMeasurementsEvent.Callback() {
        @Override
        public void onGnssMeasurementsReceived(GnssMeasurementsEvent eventArgs) {
        super.onGnssMeasurementsReceived(eventArgs);

        Log.d(TAG, "onGnssMeasurementsReceived: invoked!");

        for (CalculationModule calculationModule : CalculationModulesArrayList.this)
            calculationModule.updateMeasurements(eventArgs);

        if(mPoseUpdatedListener !=null)
            mPoseUpdatedListener.onPoseUpdated();
        }
    };

    locationRequest = new LocationRequest();

    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setMaxWaitTime(500);
    locationRequest.setInterval(1000);
    locationRequest.setFastestInterval(100);

    locationCallback = new LocationCallback(){
        @Override
        public void onLocationResult(LocationResult locationResult) {

        final Location lastLocation = locationResult.getLocations().get(locationResult.getLocations().size()-1);

        if(lastLocation != null) {
            synchronized (this) {
                for (CalculationModule calculationModule : CalculationModulesArrayList.this)
                    calculationModule.updateLocationFromGoogleServices(lastLocation);

            }
        }
        }
    };
}
 
Example #24
Source File: ControllerFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    super.onLocationResult(locationResult);
    if (weakLocationCallback.get() != null) {
        weakLocationCallback.get().onLocationResult(locationResult);
    }
}
 
Example #25
Source File: DriverMapActivity.java    From UberClone with MIT License 5 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    for(Location location : locationResult.getLocations()){
        if(getApplicationContext()!=null){

            if(!customerId.equals("") && mLastLocation!=null && location != null){
                rideDistance += mLastLocation.distanceTo(location)/1000;
            }
            mLastLocation = location;


            LatLng latLng = new LatLng(location.getLatitude(),location.getLongitude());
            mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
            mMap.animateCamera(CameraUpdateFactory.zoomTo(11));

            String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
            DatabaseReference refAvailable = FirebaseDatabase.getInstance().getReference("driversAvailable");
            DatabaseReference refWorking = FirebaseDatabase.getInstance().getReference("driversWorking");
            GeoFire geoFireAvailable = new GeoFire(refAvailable);
            GeoFire geoFireWorking = new GeoFire(refWorking);

            switch (customerId){
                case "":
                    geoFireWorking.removeLocation(userId);
                    geoFireAvailable.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()));
                    break;

                default:
                    geoFireAvailable.removeLocation(userId);
                    geoFireWorking.setLocation(userId, new GeoLocation(location.getLatitude(), location.getLongitude()));
                    break;
            }
        }
    }
}
 
Example #26
Source File: CustomerMapActivity.java    From UberClone with MIT License 5 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    for(Location location : locationResult.getLocations()){
        if(getApplicationContext()!=null){
            mLastLocation = location;

            LatLng latLng = new LatLng(location.getLatitude(),location.getLongitude());

            //mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
            //mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
            if(!getDriversAroundStarted)
                getDriversAround();
        }
    }
}
 
Example #27
Source File: HomeFragment.java    From SEAL-Demo with MIT License 5 votes vote down vote up
@Override
public void onLocationResult(LocationResult locationResult) {
    List<Location> locationList = locationResult.getLocations();
    if (!locationList.isEmpty()) {
        Location location = locationList.get(locationList.size() - 1);
        Log.i(TAG, "Location: " + location.getLatitude() + " " + location.getLongitude());
        //Place current location marker
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        //move map camera
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, MAP_ZOOM));
    }
}
 
Example #28
Source File: AndroidLocationProvider.java    From BLE-Indoor-Positioning with Apache License 2.0 5 votes vote down vote up
private LocationCallback createLocationCallback() {
    return new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            Log.v(TAG, "Received location result with " + locationResult.getLocations().size() + " locations");
            onLocationUpdateReceived(locationResult.getLastLocation());
        }
    };
}
 
Example #29
Source File: AndroidLocationPlayServiceManager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
static android.location.Location extractLocationFromIntent(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        if (locationResult == null) {
            return null;
        }
        return locationResult.getLastLocation();
    } else {
        return intent.getParcelableExtra(FusedLocationProviderApi.KEY_LOCATION_CHANGED);
    }
}
 
Example #30
Source File: LocationGetLocationActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@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);
                }
            }
        }
    };
}