开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜