开发者

Getting driving speed in an Android app

How can I develop a program in android to view the speed of the android holder ?

I need 开发者_C百科to develop a program that determine location and the speed of the android mobile holder if he drive.now I know how to determine the current location of the android mobile holder but i don't know how can i determine his speed . I hope it clear now


The namespace android.location contains a lot of useful classes. Basically what you need is to use Context.getSystemService(Context.LOCATION_SERVICE) and then with LocationManager.requestLocationUpdates() you can subscribe to listen location updates for a provider. To determine the speed you need to listen the LocationManager.GPS_PROVIDER. From a Location you can call getSpeed(). Of course determining the speed needs a proper amount of satellite fixes so a given Location result may not always contain the speed nor bearing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜