I am facing an issue with the data provided from GPS.
I am calculating the distance upon the location change callback
, so when the device is idle the distance getting incremented due to the GPS fluctuation.
I have been using FusedLocationProviderClient for getting the location update.
fusedLocationClient.requestLocationUpdates(locationRequest,
locationCallback, Looper.myLooper());
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
onNewLocation(locationResult.getLastLocation());
}
};
private void createLocationRequest() {
locationRequest = new LocationRequest();
locationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
locationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}