在Android手机中计算GPS距离的最佳方法是什么?

时间:2017-01-12 06:39:10

标签: android gps android-gps

我正在开发一款每60秒捕获用户纬度和经度的应用,并计算用户行进的距离。 有时我的手机在同一个位置超过一个小时,但GPS会跳到不同的位置导致错误的距离计算。

如何减少gps跳跃并提高距离准确度?

2 个答案:

答案 0 :(得分:0)

整个会话期间GPS的准确性将不一致。但有办法克服这一点。即使用户没有改变位置,仍然是latitide,经度值在连续的时间段内会有所不同。请查看以下方法如何修改这些异常。

// for location updates
private int locationupdate = 8000; //in milliseconds
private int locationdistance = 10; // in meters

在创建位置请求时,请根据您的要求提及setSmallestDisplacement以及setInterval,如下所示

protected void createLocationRequest() {
    locationRequest = new LocationRequest();
    locationRequest.setInterval(locationupdate); //in milliseconds
    locationRequest.setFastestInterval(5000); //in milliseconds
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setSmallestDisplacement(locationdistance);
}

查看this link了解详情

答案 1 :(得分:0)

如果不够好,你必须检查位置的准确性。

can't find the exact current location in android

相关问题