Skip to content

Instantly share code, notes, and snippets.

@hitherejoe
Created July 7, 2015 08:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitherejoe/4353a016c4c05df2c5b1 to your computer and use it in GitHub Desktop.
Save hitherejoe/4353a016c4c05df2c5b1 to your computer and use it in GitHub Desktop.
Andriod M - Request single permission
private static final int REQUEST_LOCATION = 1503;
private void requestSinglePermission() {
String locationPermission = Manifest.permission.ACCESS_FINE_LOCATION;
int hasPermission = checkSelfPermission(locationPermission);
String[] permissions = new String[] { locationPermission };
if (hasPermission != PackageManager.PERMISSION_GRANTED) {
requestPermissions(permissions, REQUEST_LOCATION);
} else {
// Phew - we already have permission!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment