How would I go about tracking the distance a user travels? I don't necessarily care about storing waypoints, although that may be necessary to calculate distance anyway.
So far, I am creating a LocationManager and regsitering an onLocationChanged listener, and then calculating the raw distance between two points when the listener fires.

The problem here is that if I leave the app sit still on a desk for 10, 15 minutes, it will say I have traveled .5 miles. How should I go about checking for accuracy and determining which points to use?

Or, even better - is there an SDK or .jar I can just include in my project and call their functions to make this whole thing easier?

2 Answers
2

I am not an Android programmer but have implemented this functionality in my own embedded processor with far less processing capability than anything that runs Andriod.

This is nothing to do with the accuracy of a fix as determined by the GPS. If you have a stationary GPS receiver with "perfect" visibility of the sky and plot its reported position over time then you will see it wander around the true location, moving some metres an any direction. If you accumulate the distance travelled, in very small steps, around the true position you will end up with the distance travelled apparently taking you to the moon and back.

You need to set a movement threshold that is greater than the position accuracy of your GPS fix, and then only add in the distance travelled when you are sure that you have moved from the point at which you added in the last movement step.

You can call getAccuracy() on the Location object it gives you to check the accuracy. If your app needs to be real accurate, you can only count values with a high accuracy.

You can also call getProviders() on the LocationManager to check to see if you're getting coordinates from wifi, gps, or both, and ask the user to use their gps if it's not currently turned on so that you get more accurate points.

I'm completely new to this realm of science. How accurate is considered good enough to use? Is there no better way to determine whether or not the user has moved?
–
DefZepMay 30 '12 at 14:42

That's up to you really, and how important accuracy is to the functionality of your application. Just know that the GPS never works well inside buildings, so it's probably not ever going to be better than 5-20m inside. And that's the only way I can currently think of to know if they've moved. That's what LocationManager and onLocationChanged were made for.
–
BraydenMay 30 '12 at 15:21

(BTW Accuracy is returned to in a value of meters. So if it returns an accuracy of 5, they are probably within a 5 meter radius of the location returned).
–
BraydenMay 30 '12 at 15:23

One last question - I'm assuming the accuracy is in a radius. Ex: acc of 5 = 5m any direction but in total a 10 meter diameter sphere/circle that the user is possibly in. Does that sound right?
–
DefZepJun 1 '12 at 14:44