Created
April 21, 2015 07:51
-
-
Save akoul889/89c0d9c8cb22aca4ee33 to your computer and use it in GitHub Desktop.
Check Location Enabled
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
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