react-native-image-crop-picker
react-native-image-crop-picker copied to clipboard
Always returns "User cancelled image selection" if more then one camera app is installed on Android device
Version
Tell us which versions you are using:
- react-native-image-crop-picker v0.25.2
- react-native v0.60.5
Platform
Tell us to which platform this issue is related
- Android
Expected behaviour
The openCamera function should resolve the promise with imageData.
Actual behaviour
The openCamera function always rejects the promise with error "User cancelled image selection"
Steps to reproduce
- Install another camera app in the Android device
- Then in the app with basic setup call openCamera function with following options object
{ width: 200, height: 200, cropping: false, cropperCircleOverlay: false, mirrorImage: true, compressImageQuality: 0.5, forceJpg: true, writeTempFile: false, includeBase64: true, }
- It should get resolved but it is always rejecting the promise
Attachments
// stacktrace or any other useful debug info
Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate
Does it happen in every device? Here can not recreate the issue.
I think one more important thing is.. no default camera app should be set. I have tested on LG-H870DS with Android 8.0 and latest OnePlus-6 device. On both the devices its rejecting the promise.
which other camera app did you use? I tested on my note9 it works fine though.
I have tried with 2 different apps. One is HD Camera (KX Camera Team). And another is Camera MX.
I have tried with 2 different apps. One is HD Camera (KX Camera Team). And another is Camera MX.
maybe related to android version or something. I couldn't reproduce. I was interested as one user of a production app faced this type of issues, so tried to recreate it based on this.
react-native-image-crop-picker" "0.28.0 Samsung A8+ installed OpenCamera (in addition to stock-app).
If no default camera selected Picker throws:
[Error: User cancelled image selection] {"framestopop":1,"nativestackandroid":[],"userinfo":null,"message":"user cancelled image selection","code":"e_picker_cancelled","line":5020,"column":45 }
After Camera set as default (Use any camera Always) - picker works as intended. Issue reproduces after "Default Camera" resets.
I was facing the same problem. After looking into it, I found that, in my manifest file, main activity was being launched with android:launchMode="singleInstance". After changing it to android:launchMode="singleTop", the app was able to handle camera intents with multiple apps correctly.
Here is the doc with all launch modes information: https://developer.android.com/guide/topics/manifest/activity-element
<activity android:name=".MainActivity" android:launchMode="singleTop"