Skip to content

Instantly share code, notes, and snippets.

@JosiasSena
Created July 15, 2016 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosiasSena/38670b172b4f4e68ac86a856d785b085 to your computer and use it in GitHub Desktop.
Save JosiasSena/38670b172b4f4e68ac86a856d785b085 to your computer and use it in GitHub Desktop.
check if GPS is enabled
/**
* Returns the current enabled/disabled status of the GPS provider.
* <p/>
* If the user has enabled GPS in the Settings menu, true
* is returned otherwise false is returned
*/
public static boolean isGpsEnabled(final Context context) {
final LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment