Skip to content

Instantly share code, notes, and snippets.

@akoul889
Created April 21, 2015 07:51
Show Gist options
  • Save akoul889/89c0d9c8cb22aca4ee33 to your computer and use it in GitHub Desktop.
Save akoul889/89c0d9c8cb22aca4ee33 to your computer and use it in GitHub Desktop.
Check Location Enabled
private boolean isLocationEnabled() {
int locationMode = 0;
String locationProviders;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
try {
locationMode = Settings.Secure.getInt(getContentResolver(), Settings.Secure
.LOCATION_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return locationMode != Settings.Secure.LOCATION_MODE_OFF;
}else{
locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment