michael wrote:
> I am developing a Service that uses location information. I want it to
> always use the "best" enabled LocationProvider according to a given
> Criteria object. For this I initially use the following method:
> 
> LocationManager.getBestProvider(Criteria criteria, boolean
> enabledOnly)
> 
> with enabledOnly set to "true", and I then register my
> LocationListener with the result.
> 
> My question is the following: how do I know when new providers become
> available in order to re-invoke getBestProvider()? I have come up with
> two solutions, neither of which seem satisfactory:
> 
> 1) Register a listener for all available providers, whether or not
> they are enabled, and override the onProviderDisabled,
> onProviderEnabled and onStatusChanged methods. But then the listener
> also gets unnecessary calls to onLocationChanged which I don't want to
> happen due to performance/battery constraints.
> 
> 2) Run a background thread which periodically invokes
> LocationManager.getBestProvider and checks if there are any changes.
> Again this seems like an unnecessary overhead.
> 
> Is there a better approach that I am overlooking? Any suggestions
> would be much appreciated.

3) Don't worry about the problem. The only reason that the provider
indicated by your Criteria will change is if the user enables or
disables a provider in the Settings application, which I doubt happens
on the fly very frequently.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.5 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to