LatLng and distance between returned incorrect values ​​on new phones

My application works fine on my old HTC One M7 in terms of distance calculation. However, on my wife HTC One M8 and on my new Sony Xperia Z3, the distance that he calculates is disabled. This tells me that I went further than it actually is. I noticed this more when I went or ran. If I ski, it seems more accurate. I assume that speed has something to do with it (if I am faster, the calculations are more accurate).

I call the update method of my total distance every time I change location, which does this:

float[] distanceResults = new float[3];
double distanceResult = 0;
try
{
    Location.distanceBetween(location.getLatitude(), location.getLongitude(), previousLocation.getLatitude(), previousLocation.getLongitude(), distanceResults);
    distanceResult = distanceResults[0];
}
catch(IllegalArgumentException e)
{
    distanceResult = 0;
}
// add the new distance to the total distance
totalDistanceValue += distanceResult;

, . 20 , ... .

- , , , ?

0
1

, . , , google , . .

@Override
public void onLocationChanged(Location location) {
        if (!location.hasAccuracy()) {
            return;
        }
        if (location.getAccuracy() > 4) {
            return;
        }

 //process location accurate to 4 meters
 }
0

Source: https://habr.com/ru/post/1568281/


All Articles