I'm using gps to calculate the speed
But sometimes I get incorrect values
For example, I keep walking at a speed of 4 km/h, but suddenly the value shows that I am walking at 10 km/h, and then the value of 4 km/h comes back to normal.
Is there any way to correct this value?
thank you
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 0.0f, gpsListener);
@Override
public void onLocationChanged(Location location)
{
if(lastLocation != null)
{
if(location.hasSpeed())
{
currentSpeed = location.getSpeed();
} else {
double deltaTime = (location.getTime() - lastLocation.getTime()) / 1000.0;
currentSpeed = lastLocation.distanceTo(location) / deltaTime;
}
}
lastLocation = location;
}