Vivo Android 10 throw "User cancelled image selection" error when call openPicker method
Version
Tell us which versions you are using:
- react-native-image-crop-picker v0.38.0
- react-native v0.69.4
Platform
Tell us to which platform this issue is related
- ~~iOS~~
- Android
Expected behaviour
The openPicker method for Vivo Android 10 phones is as good as other Android phones
Actual behaviour
When call openPicker method, Vivo phone doesn't display native file selection page, but returns User cancelled image selection error immediately.
Device Info
Device: Vivo S7 (V2020A) ROM Version: OriginOS (PD2020_A_7.8.5) Android Version: Android 10
Steps to reproduce
-
Get a Vivo Android 10 Phone
-
Run react-native-image-crop-picker example on Vivo Phone
-
Press
Select Singlebutton
What I tried
- Try inside catch error
- Android - startActivityForResult immediately triggering onActivityResult
- Android - startActivityForResult immediately triggering onActivityResult
Share a temporary solution
-
Make sure your project
android/app/src/main/AndroidManifest.xmlislaunchMode="singleTop" -
Replace node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/
PickerModule.javafinal Intent chooserIntent = Intent.createChooser(galleryIntent, "Pick an image"); activity.startActivityForResult(chooserIntent, IMAGE_PICKER_REQUEST);to
activity.startActivityForResult(galleryIntent, IMAGE_PICKER_REQUEST);
Attachments
I debugged with Android Studio and found the following: Clicking the Select Single button will call the startActivityForResult method, if it's a normal phone, the native file selection page will be displayed, after selecting the files, onActivityResult method will be callback with the file data, but Vivo will immediately callback onActivityResult method, and get resultCode: 0, data: null, here is why it throw User cancelled image selection error.

Maybe Vivo Android 10 Rom not support createChooser ?, I'm not sure...
Maybe the same issue
#1816
Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate