Determining if user is driving using gps

浪子不回头ぞ 提交于 2019-12-22 16:45:33

问题


Is there a way in Android to somehow use the GPS to determine if the user is driving (e.g. if the user is moving faster then say, 10 mph)? What would be even better is if there was an intent I could receive whenever the user is moving faster then 10 mph or under 10 mph, but I think I'm pushing my luck with that one.

Any help would be appreciated.


回答1:


You probably want to set up some AsyncTask (background thread) with a call back function of your preference, which will be called when the speed is over 10 MPH. You can use the Location.GetSpeed() function.

Also, you might want to take note of the fact that it returns in meters/second. But this is a trivial conversion.



来源:https://stackoverflow.com/questions/6990926/determining-if-user-is-driving-using-gps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!