Search code examples
javaandroidgpsaccelerometer

GPS is fluctuating when the device moves slowly or stands still


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);
}

Solution

  • The positioning accuracy of GPS is not better than 4 or 5 meters. that is, each time a position is calculated it can be within a radius never less than about 4 meters. Some time the calculated position will be displaced meters to the front, sometimes to the left, back, etc.

    If you want those small variations not to be taken into account, it must be your code that discriminates if the user has really moved.

    It sounds difficult, yes, but this is the merit for an application or GPS device to calculate near to correct distances.