Cordova plugin camera: error getting “no image selected” on Android 4.4 device
I am using ionic 1. X to develop hybrid mobile applications. At present, I am dealing with strange behaviors related to Cordova plugin camera on devices running Android 4.4 (KitKat – also tested in 4.3). When I run the following code:
var options = {
quality: 50,
mediaType: Camera.MediaType.PICTURE,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
saveToPhotoAlbum: false,
correctOrientation: true
};
navigator.camera.getPicture(function (imageData) {
console.log(imageData);
}, function (err) {
console.log(err);
}, options);
The error callback will be triggered immediately and output "no image selected" to the console. That is, before I take a picture, open the camera application and trigger the error callback when I open the camera
But the same code applies to devices with a new Android Version (tested on Android 7.0 devices)
I am using:
> Cordova 8.0 > cordova-android 6.4.0 > cordova-plugin-camera 4.0.2
Tried this solution, but got the same result. So, how can I solve this problem? Did I forget anything?
Thank you for your help
resolvent:
After two days of work and 30 minutes of this article on stackoverflow, the problem was solved according to the steps described in this GitHub comment:
>Add the following line to config.xml: < preference name = "androidlaunchmode" value = "singletop" / > > delete directory platform / Android / > Run Cordova to prepare Android
It seems that the problem is caused by the Cordova plugin background mode plug-in I installed