Well, then the docs or the implementation should be fixed and you are welcomed to wait when it will be resolved ;)
The concept of "getBestProvider" assume you have hundreds of providers but don't know what is the best one. In the reality there are only 2 providers available on most of the production level Android devices: network and GPS. So if you want to make sure your code uses network provider then use its name directly, for example: locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); When you prefer to use GPS use LocationManager.GPS_PROVIDER You don't need to use an API just because someone published it, especially when it doesn't work as you expect. On Mar 3, 10:56 am, Jake Colman <[email protected]> wrote: > According to the docs, all These constrains, but for cost, are supposed > to be relaxed until it can find a provider. Because, otherwise, how can > I make sure it only uses network even if gps is available? > > >>>>> "i" == ip <ip332> writes: > > i> Because there is no provider to match your criteria. Most likely > i> because both providers don't have "POWER_LOW". You can figure out > i> the exact answer by removing Power constrain from the criteria and > i> checking the output. > > i> On Mar 3, 8:40 am, Jake Colman <[email protected]> wrote: > >> I am using the following code to get a list of all available providers, > >> so I can see what's out there, and to select the best provider based on > >> my criteria. Why would this code return a list of "[network gps]" for > >> all providers but still return null for best provider? > >> > >> List<String> all = locationManager.getAllProviders(); > >> logger.verbose( TAG, "All available location providers: " + > >> all.toString() ); > >> > >> Criteria criteria = new Criteria(); > >> criteria.setAccuracy( Criteria.ACCURACY_COARSE); > >> criteria.setAltitudeRequired( false ); > >> criteria.setBearingRequired( false ); > >> criteria.setCostAllowed( true ); > >> criteria.setPowerRequirement( Criteria.POWER_LOW); > >> > >> String provider = locationManager.getBestProvider( criteria, true); > >> logger.verbose( TAG, "Best location provider: " + provider ); > >> > >> I am getting this behavior on the emulator but I suspect that this may > >> be the root cause of an issue seen by one of my users. > >> > >> -- > >> Jake Colman -- Android Tinkerer > > i> -- > i> You received this message because you are subscribed to the Google > i> Groups "Android Developers" group. > i> To post to this group, send email to [email protected] > i> To unsubscribe from this group, send email to > i> [email protected] > i> For more options, visit this group at > i>http://groups.google.com/group/android-developers?hl=en > > -- > Jake Colman -- Android Tinkerer -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

