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 | |
} | |
} |
- in this case, do I need to override onRequestPermissionsResult() ??
and what will I check there? (all the permissions requested)? - I try it(the code above) I just get one dialogue, thus one request!! when allow I wait for another and not get it..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have the full code somewhere on github? I trying to figure out how to invoke https://medium.com/exploring-android/handling-android-runtime-permissions-in-ui-tests-981f9dc11a4e#.zew5w8sjg this method and also implmentations of
checkSelfPermission
andrequestPermissions