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 void requestMultiplePermissions() { | |
String locationPermission = Manifest.permission.ACCESS_FINE_LOCATION; | |
String calendarPermission = Manifest.permission.WRITE_CALENDAR; | |
int hasLocPermission = checkSelfPermission(locationPermission); | |
int hasCalPermission = checkSelfPermission(calendarPermission); | |
List<String> permissions = new ArrayList<String>(); | |
if (hasLocPermission != PackageManager.PERMISSION_GRANTED) { | |
permissions.add(locationPermission); | |
} | |
if (hasCalPermission != PackageManager.PERMISSION_GRANTED) { | |
permissions.add(calendarPermission); | |
} | |
if (!permissions.isEmpty()) { | |
String[] params = permissions.toArray(new String[permissions.size()]); | |
requestPermissions(params, REQUEST_PERMISSIONS); | |
} else { | |
// We already have permission, so handle as normal | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and what will I check there? (all the permissions requested)?