I need to calculate the movement speed on every location update.
I’m using the following code for the location update.
public class FlirtLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location location)
{
// My Code on the location update
}
@Override
public void onProviderDisabled(String provider)
{
Log.i("OnProviderDisabled", "OnProviderDisabled");
}
@Override
public void onProviderEnabled(String provider)
{
Log.i("onProviderEnabled", "onProviderEnabled");
}
@Override
public void onStatusChanged(String provider, int status,
Bundle extras)
{
Log.i("onStatusChanged", "onStatusChanged");
}
}
How to get the movement speed? Should I calculate the time between the two updates and the distance between first and next location? Or is there some other way?
As @jsmith said there is a
getSpeed()method in theLocation.class.