Last active
September 5, 2017 10:25
-
-
Save danikx/f4d1e8c9975e3a7f3a926ee477bc3ab7 to your computer and use it in GitHub Desktop.
android check gps enabled (method 2)
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
public static boolean isGpsEnabled(){ | |
LocationManager lm = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE); | |
boolean gps_enabled = false; | |
boolean network_enabled = false; | |
try { | |
gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
} catch(Exception ex) {} | |
try { | |
network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
} catch(Exception ex) {} | |
return gps_enabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment