Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Fix permission issue (react-native-image-picker#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaBs authored and haitaoli committed May 13, 2018
1 parent 60169dc commit 694fa1d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions android/src/main/java/com/imagepicker/ImagePickerModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -601,6 +602,9 @@ public void onReTry(WeakReference<ImagePickerModule> 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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 694fa1d

Please sign in to comment.