Reputation: 6555
I'm wanting to build an application that will tell me how far I've ran. I was thinking I could keep a list of all GPS coordinates in a List and then do distance formula on them in sequential pairs. I'm not sure this is the best way to do this though. I'm also worried about the GPS picking up a "bad" coordinate and ruining my recorded distance.
Thanks
Upvotes: 1
Views: 4750
Reputation: 5747
As far as the 'bad' coordinate problem goes, the Location object that your application gets from the LocationManager has an accuracy value; if you're worried about bad data, you could discard any value with low accuracy. You could also run a filter on your data to eliminate any really far outlying data points.
For tracking the data, you could keep the points in a list. Or, if you want to persist them from run to run, you could track them in a SQLite database. Then you could view/compare all of your runs later.
Upvotes: 2
Reputation: 80330
Use LocationManager.requestLocationUpdates(..)
to register your LocationListener.
Also use such Criteria, so that only updates with certain accuracy get reported.
This is a very nice tutorial on acquiring location on Android: http://developer.android.com/guide/topics/location/obtaining-user-location.html
Upvotes: 2