cordova-plugin-camera: Error "No Image Selected"
It doesn’t work when I using the captured image using the camera. It always returns “No Image Selected”.
Code 1
function getpic()
{
navigator.camera.getPicture(cameraCallback, onFail,
{
destinationType: Camera.DestinationType.DATA_URL
});
}
function cameraCallback(imageData)
{
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message)
{
alert('Failed because: ' + message);
}
Code 2
function getpic()
{
navigator.camera.getPicture(cameraCallback, onFail,
{
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA ,
});
}
function cameraCallback(imageData)
{
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message)
{
alert('Failed because: ' + message);
}
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 6
- Comments: 28 (3 by maintainers)
I’m here in 2021 with the same error. Anyone have clear the status ? Exists a way to solve it ?
“cordova-plugin-camera”: “4.1.0”, Android 9,10 We constantly get this error on different phones with Android 9-10 if user has several installed camera apps and he don’t choose any as default, in other words - if you have choose camera app dialog you will get this error from native, so please fix it
This workaround only works until Android 11, because Android 11 does not let you select your default camera app anymore.
See https://9to5google.com/2020/08/18/android-11-default-camera-app-changes/
Further links:
However, the Snapdragon camera worked again once we’ve changed our
config.xml
:<preference name="AndroidLaunchMode" value="singleInstance"/>
to
<preference name="AndroidLaunchMode" value="singleTask"/>
See https://developer.android.com/guide/topics/manifest/activity-element#lmode This allowed us to continue usage of this camera plugin together with Android 11 and the Honeywell EDA52.
It’s not the camera app part - or maybe it’s not only that - if you have
allowEdit:ture
in your params, and you have one or more application that can do the cropping/editing ( and have no default selected ) then you’ll face the same problemPlease FIX … thanks!
this worked for me.
I had the same error when getPicture was called twice. Be sure your function getpic() is called only once
For the Hotfix, I just remove the edit option. but it’s a bug “no select image.” I need to fix it in the future.
can you please add the path.
Same for me! Zebra TC 25 (Android 7.1.2) with default camera App
Snapdragon-Kamera
always returnedNo Image Selected
(I guess this is just an incompatible camera App with this Cordova Plugin), so I tried a different Camera App Open Camera which didn’t work either until I selected a new default camera. So guys with multiple cameras, choose a default one!By the way: The first time I used the new camera app, the camera selection dialog came up (Open Camera or Snapdragon Camera. Only this time or Always); I selected Open Camera as a default (Always), but at the first usage, it still didn’t work in my Cordova app, because the camera selection dialog seems to break the Cordova Plugin Camera callback. It works since then.
If you have the problem
No Image Selected
:Tested with two versions:
The issue occurs when having multiple camera apps on your device. Tested and verified on Realme 2 pro and Pixel 3 XL (both android 10)
@jcesarmobile I am checked it is working if we have only one camera application. But not if many camera application. I am checked Android only.
Cannot replicate this in Android or iOS.