I am currently working on an application focused around fitness. The basic I idea is to allow to people to track their speed,distance,time. So far I have managed to get spee
Try using this: http://googlemaps.github.io/android-maps-utils/javadoc/com/google/maps/android/SphericalUtil.html
For each location you get, you create a LatLng and added it to a ArrayList. Then with this function it gets you the correct length:
SphericalUtil.computeLength(latLngs);
Gradle:
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.4+'
}
EDIT: You have an Arraylist locations = new ArrayList globally. And in your "onLocationChanged" you add to the locations:
@Override
public void onLocationChanged(Location location) {
locations.add(location);
}
Then when needed you do:
for (Location loc : locations){
latLngs.add(new LatLng(loc.getLocation().getLat(), loc.getLocation().getLng()));
}
Double dist = SphericalUtil.computeLength(latLngs);