In Google Map API V2
You have LatLng
objects so you can't use distanceTo
(yet).
You can then use the following code considering oldPosition and newPosition are LatLng
objects :
// The computed distance is stored in results[0].
//If results has length 2 or greater, the initial bearing is stored in results[1].
//If results has length 3 or greater, the final bearing is stored in results[2].
float[] results = new float[1];
Location.distanceBetween(oldPosition.latitude, oldPosition.longitude,
newPosition.latitude, newPosition.longitude, results);
For more informations about the Location
class see this link
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…