Reputation: 13071
How can I develop a program in android to view the speed of the android holder ?
I need 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
Upvotes: 1
Views: 1013
Reputation: 728
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.
Upvotes: 4