How to determine the velocity of an Android device?
What is the easiest way to find 开发者_如何学Cout how fast the Android device is traveling?
Also, is there a way to register an intent for speed? Example: intent if the device goes more than 20 miles an hour.
The easiest way is to get the speed of the device is from the GPS, more specifically the time it takes to travel between 2 points. Luckily this is already done for you with the Location class: Location.getSpeed()
which returns a float with the speed in m/s.
See the Android developer reference for more info
you can calculate speed precisely by multiplying acceleration to time it was applied for. this method is very sensitive so you will have to add some border check to filter shakes.
精彩评论