ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.16k stars 1.56k forks source link

Always returns "User cancelled image selection" if more then one camera app is installed on Android device #1152

Open im-aditya opened 5 years ago

im-aditya commented 5 years ago

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

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

  1. Install another camera app in the Android device
  2. 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, }

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

sadi304 commented 5 years ago

Does it happen in every device? Here can not recreate the issue.

im-aditya commented 5 years ago

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.

sadi304 commented 5 years ago

which other camera app did you use? I tested on my note9 it works fine though.

im-aditya commented 5 years ago

I have tried with 2 different apps. One is HD Camera (KX Camera Team). And another is Camera MX.

sadi304 commented 5 years ago

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.

VBarzionov commented 4 years ago

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.

julianrod94 commented 4 years ago

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

julianrod94 commented 4 years ago

<activity android:name=".MainActivity" android:launchMode="singleTop"