From 694fa1de5cf4a3dce8e135054c3831fba85e3880 Mon Sep 17 00:00:00 2001 From: David Alexander Bjerremose Date: Sun, 13 May 2018 19:33:49 +0200 Subject: [PATCH] Fix permission issue (#848) --- .../src/main/java/com/imagepicker/ImagePickerModule.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/src/main/java/com/imagepicker/ImagePickerModule.java b/android/src/main/java/com/imagepicker/ImagePickerModule.java index c3cb1ac14..0a8dfb560 100644 --- a/android/src/main/java/com/imagepicker/ImagePickerModule.java +++ b/android/src/main/java/com/imagepicker/ImagePickerModule.java @@ -49,6 +49,7 @@ import java.util.List; import com.facebook.react.modules.core.PermissionListener; +import com.facebook.react.modules.core.PermissionAwareActivity; import static com.imagepicker.utils.MediaUtils.*; import static com.imagepicker.utils.MediaUtils.createNewFile; @@ -601,6 +602,9 @@ public void onReTry(WeakReference moduleInstance, { ((ReactActivity) activity).requestPermissions(PERMISSIONS, requestCode, listener); } + else if (activity instanceof PermissionAwareActivity) { + ((PermissionAwareActivity) activity).requestPermissions(PERMISSIONS, requestCode, listener); + } else if (activity instanceof OnImagePickerPermissionsCallback) { ((OnImagePickerPermissionsCallback) activity).setPermissionListener(listener); @@ -611,6 +615,8 @@ else if (activity instanceof OnImagePickerPermissionsCallback) final String errorDescription = new StringBuilder(activity.getClass().getSimpleName()) .append(" must implement ") .append(OnImagePickerPermissionsCallback.class.getSimpleName()) + .append(" or ") + .append(PermissionAwareActivity.class.getSimpleName()) .toString(); throw new UnsupportedOperationException(errorDescription); }