Created
July 31, 2018 12:02
-
-
Save c4software/69d0342281f42d3b76f81efca3935620 to your computer and use it in GitHub Desktop.
Test if user have enabled the Android Location Service.
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 locationServiceEnabled() { | |
final LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); | |
if (locationManager != null) { | |
try { | |
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || | |
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
} catch (final Exception e) { | |
Timber.e(e); | |
return false; | |
} | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment