react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

Vivo Android 10 throw "User cancelled image selection" error when call openPicker method

Open Aliveing opened this issue 3 years ago • 0 comments

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

  1. Get a Vivo Android 10 Phone

  2. Run react-native-image-crop-picker example on Vivo Phone

  3. Press Select Single button

What I tried

  1. Try inside catch error
  2. Android - startActivityForResult immediately triggering onActivityResult
  3. Android - startActivityForResult immediately triggering onActivityResult

Share a temporary solution

  1. Make sure your project android/app/src/main/AndroidManifest.xml is launchMode="singleTop"

  2. Replace node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java

    final 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.

image image

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

Aliveing avatar Aug 18 '22 07:08 Aliveing