I need my app to perform different operations depending on how fast the person holding the phone is moving. I figured the best way to do this would be: (In pseudo code)
function mySpeed(){
float speed = location.getSpeed();
if(speed > minSpeed){
// Do this
}else{
// Do that
}
}
How well would getSpeed() work in this case? Is there a better way anyone can think of. Maybe accelerometer?
The getSpeed() method is as accurate as the locations provided by the GPS. Depending on where you are this could be +/- walking speed in any direction. A better way would be to compute the speed over a larger direction if you can make that work. Get and save one location, then watch positions until the distance between the saved location and the current one is a few hundred meters, then use distance/timedifference to compute the speed.
I can’t imagine that integrating the accelerometer over a long period of time (which you would have to do to compute speed) would be very accurate at all, but may be worth a try.