bug: Camera.getPhoto with source "PHOTO" returns "No image picked" when choosing between multiple gallery apps
See original GitHub issueBug Report
Capacitor Version
Installed Dependencies:
@capacitor/cli 1.3.0
@capacitor/android 1.3.0
@capacitor/ios 1.3.0
@capacitor/core 1.3.0
Affected Platform(s)
- Android
- iOS
- Electron
- Web
Current Behavior
Error “No image picked” is returned.
Expected Behavior
The selected image should be returned
Sample Code or Sample Application Repo
Camera.getPhoto({
source: CameraSource.Photos
});
Reproduction Steps
- Have multiple gallery apps installed on your device (in my case “Gallery Go by Google Photos” and “Google Photos”
- Trigger the
getPhoto
call, the OS should now show a dialog asking which app you want to use - Choose an app and select a photo
- getPhoto resolves with the error “No image picked”
Other Technical Details
npm --version
output: 6.9.0
node --version
output: v12.13.0
Android version: 10 Device: Goole Pixel 3a
Other Information
I debugged into the Camera plugin, the error is returned because data
is null in
public void processPickedImage(PluginCall call, Intent data) {
if (data == null) {
call.error("No image picked");
return;
}
...
}
So the data
passed to the handleOnActivityResult
method, which then calls processPickedImage,
is null when Android decides to show the app selection dialog. I am not sure if it is even an issue with capacitor or if android itself is the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Camera and Image picker in Ionic 5 apps - Enappd
Learn how to pick images in Ionic 5 app using Camera and image picker. Understand the details and test on a demo android...
Read more >Camera Capacitor Plugin API
Allows the user to pick multiple pictures from the photo gallery. On iOS 13 and older it only allows to pick one picture....
Read more >image_picker | Flutter Package - Pub.dev
Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera.
Read more >android - Capture Image from Camera and Display in Activity
Here's an example activity that will launch the camera app and then retrieve the image and display it. package edu.gvsu.cis.masl.camerademo; ...
Read more >Take a picture using the camera - Flutter documentation
Many apps require working with the device's cameras to take photos and videos. ... paths to store images. path: Creates paths that work...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Facing the same problem. After the image is taken from Camera there is no option to select that image. If you try to select image from Gallery then also no option to say use this image. tested on: Samsung galaxy edge 7 Cause of problem is
allowEditing
. When this is set to true. The image editor is opened. Now if you don’t edit your image obviously there will be no ‘Save Changes’ button. So there is only close button and this button closes the editor and also pass data is null. Workaround for us:Fix
handleOnActivityResult
intent is from Editing and if data is null. just don’t do anything. Cause image url we have already from ‘pickImage’ intent.@Alain1405 can you please have look on it?
It’s not related to the prompt, but to the app used to pick the image. Which one did you use? Device and android version are helpful too.
Also a sample app would be helpful to make sure you are not doing something wrong, I’ve just tested the “Gallery go by Google Photos” app and works fine on my device.