Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Android provider criteria
* Get provider name.
* @return Name of best suiting provider.
* */
String getProviderName() {
LocationManager locationManager = (LocationManager) this
Criteria criteria = new Criteria();
criteria.setPowerRequirement(Criteria.POWER_LOW); // Chose your desired power consumption level.
criteria.setAccuracy(Criteria.ACCURACY_FINE); // Choose your accuracy requirement.
criteria.setSpeedRequired(true); // Chose if speed for first location fix is required.
criteria.setAltitudeRequired(false); // Choose if you use altitude.
criteria.setBearingRequired(false); // Choose if you use bearing.
criteria.setCostAllowed(false); // Choose if this provider can waste money :-)
// Provide your criteria and flag enabledOnly that tells
// LocationManager only to return active providers.
return locationManager.getBestProvider(criteria, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.