Gps - Location update rate in Google Maps Android

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I m writing a simple GPS based app for location awareness. Whenever GPS is enabled, the app requests location updates and prints latitude and longitude in a TextView. If GPS is disabled, the location provider fall-backs to LocationManager.NETWORK_PROVIDER for triangulating device position relative to neighboring cell-towers. The aim is whenever device movement is detected, it should start populating the TextView with lat/long. When there is no movement, the process should stop. In order to do so, I ve implemented the location update rate as:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1, this);

The above line causes very frequent location updates (even when there is no movement, I keep getting lat/long values). I read somewhere that putting minTime=0 is not a good idea (battery drains faster). When I change it to 2 or 3 seconds, the update becomes very slow (even if the device moves more than 50 meters). Changing minDistance doesn t seem to work either! I want to know what settings does Google Maps application use? Power consumption is not a limiting factor for me as I m developing the app for some network drive test equipment (which gets constant power from vehicle s on-board lead acid battery).

Answers

The frequency of updates is highly dependent on the hardware. Good gps chips send very frequent updates(Samsung Galaxy S3) while some struggle even to show lat-lan position. The gist here is normalize the the frequency for receiving updates on the basis of distance and time. Use various time and distance configuration and test them and use the most appropriate values. For my project I used following values: //for walking user

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5, 10, this);

//for user in a car

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2, 50, this);

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/23379691/location-update-rate-in-google-maps-android

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils