我正在构建一个跟踪我的跑步和走路的应用程序,但我在计算总距离时遇到了一些麻烦。计算两个位置之间的距离Android Studio
这里是我的代码的一部分,我得到的纬度和经度的值,我在哪里做我的距离计算。
public class SportsActicity {
protected Integer userId;
protected ArrayList route = new ArrayList();
public SportsActicity() {
this.userId = 1;
}
public void track(Double latitude, Double longitude, Double altitude, float speed, long chron) {
Date currentDate = new Date();
Position currentPosition = new Position(currentDate, latitude, longitude, altitude, speed, chron);
route.add(currentPosition);
// Float velocidade = (locat.getSpeed()*3600)/1000;
}
public double getTotalDistance() {
double distance = 0;
if(route.size() > 1) {
for (Integer i = 0; i < route.size() - 1; i++) {
distanc