My app works great on my old HTC One M7 in terms of calculating distance. However, on my wife's HTC One M8 and on my new Sony Xperia Z3, the distance it calculates is off. It's telling me that I've gone further than I really have. I've noticed this more when I'm hiking or running. If I'm skiing, it seems to be more accurate. I'm guessing that speed has something to do with it (if I'm going faster, the calculations are more accurate).
I'm calling a method to update my total distance on every location change 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;
I can't wrap my head around why it doesn't calculate accurately on the newer phones. I thought about only calculating distance every 20th location change, but that seems like a ghetto fix for this...and may not even work.
anyone have any ideas why my total distance is more than it should be on newer phones when I'm going at a slower pace?
TIA