This seems like it should be simple enough, but I can’t seem to get a clear example of how to calculate my speed using Android’s Location Services.
All I want to do is calculate my speed based on my previous and current GPS position. getSpeed() doesn’t work, because it needs to be set at some point using setSpeed().
So is there any sample code out there that I can run in Eclipse against my Android emulator running a GPX file, that will show me my pace in any measure (meters, feet, miles, etc., doesn’t matter – I can always convert this to what I need).
Thanks in advance,
Alex
(In case you are using an actual device — ). No, the speed is determined by the GPS chipset and it should be more accurate than getting the distance and time between two consecutive locations. You do not need to
setSpeed(). CallhasSpeed()to see if the speed is valid.(In case you’re not using an actual device)
I’ve had good success using the mock location provider where you can set the
Locationobject you want withsetSpeed()in meters/secondHere are some ways of doing this :