Created
April 15, 2022 09:01
-
-
Save massimilianochiodi/45e3a88036ac668306aa2dc97d086d26 to your computer and use it in GitHub Desktop.
Location Service is active (java)
This file contains hidden or 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 localizzazioneattiva(Context context) { | |
LocationManager lm; | |
boolean gpsEnabled; | |
boolean networkEnabled; | |
lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | |
try { | |
gpsEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
} catch (Exception ex) { | |
return false; | |
} | |
try { | |
networkEnabled = lm | |
.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
} catch (Exception ex) { | |
return false; | |
} | |
return gpsEnabled || networkEnabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment