Reputation: 1236
Is it advisable to implement both LocationManager.NETWORK_PROVIDER and LocationManager.GPS_PROVIDER with the differenct listener and then unregister the listeners locationManager.removeUpdates(locationListener) ?
Because GPS_PROVIDER takes lot of time to return the values and sometimes doesn't even gives a call back?
Also, we can have a locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); in handler with a postDelayed to avoid a deadlock in case there aren't any callbacks?
Any help by anyone?
Thanks in advance!!!
BR, J
Upvotes: 2
Views: 1686
Reputation: 1236
Ideally this question wont be valid anymore, since Google finally released newer version of location listeners which would take care of this more effectively. Link for the same below: http://developer.android.com/google/play-services/location.html
Upvotes: 0
Reputation: 5242
Hm afaik locationManager.getLastKnownLocation returns instantly, so you should not see any deadlocks?
If you really need to manage your own LocationListeners, it is advisable to first register a Network-One and a two GPS-ones. Use the network-Listener to receive a first location (rough). Configure one GPS-Location-listener to receive all GPS-Updates. Once the location is accurate neough, switch to a managed GPS-Location-Listener, that only receives updates every x seconds and x meters diff. See http://developer.android.com/guide/topics/location/obtaining-user-location.html for more examples.
If you want to display the location on a map, try MyLocationOverlay. It does all that for you.
Upvotes: 1