From 5a93aa0423cb81aabeb3d7a1a6d1e4295964d292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Thei=C3=9F?= Date: Sun, 6 Mar 2016 08:43:15 +0100 Subject: [PATCH] fixed a bug that only one permission was shown to accept when multiple permissions where requested --- .../fastaccess/permission/base/PermissionHelper.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/permission/src/main/java/com/fastaccess/permission/base/PermissionHelper.java b/permission/src/main/java/com/fastaccess/permission/base/PermissionHelper.java index 73c2413..18c0a51 100644 --- a/permission/src/main/java/com/fastaccess/permission/base/PermissionHelper.java +++ b/permission/src/main/java/com/fastaccess/permission/base/PermissionHelper.java @@ -195,13 +195,20 @@ public void requestAfterExplanation(@NonNull String permissionName) { * to be called when explanation is presented to the user */ public void requestAfterExplanation(@NonNull String[] permissions) { + + ArrayList permissionsToRequest = new ArrayList<>(); + for (String permissionName : permissions) { if (isPermissionDeclined(permissionName)) { - ActivityCompat.requestPermissions(context, new String[]{permissionName}, REQUEST_PERMISSIONS); + permissionsToRequest.add(permissionName); // add permission to request } else { - permissionCallback.onPermissionPreGranted(permissionName); + permissionCallback.onPermissionPreGranted(permissionName); // do not request, since it is already granted } } + + permissions = permissionsToRequest.toArray(new String[permissionsToRequest.size()]); + + ActivityCompat.requestPermissions(context, permissions, REQUEST_PERMISSIONS); } /**