Created
April 16, 2018 13:58
-
-
Save talut/96dc1c274a7bca41c92a99b84af8f12b to your computer and use it in GitHub Desktop.
Android provider criteria
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get provider name. | |
* @return Name of best suiting provider. | |
* */ | |
String getProviderName() { | |
LocationManager locationManager = (LocationManager) this | |
.getSystemService(Context.LOCATION_SERVICE); | |
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