daveomcd
daveomcd

Reputation: 6555

Android: How can I record my distance traveled?

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

Answers (2)

E.Z. Hart
E.Z. Hart

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

Peter Knego
Peter Knego

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

Related Questions