I'm working on an hybrid mobile app build with Ionic 1.x. Currently I'm dealing with an weird behavior 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 is instantly fired and prints "No Image Selected" to console. That is: the camera app is opened and the error callback is fired while the camera is opened, before I take a picture.
But this same code works on devices with new Android versions (tested on an Android 7.0 device).
I'm using:
Have tried this solution, but getting the same result. So, how can I solve this issue? Am I forgetting something?
Thanks for the help.
After two days of working on this and 30 minutes after this post on StackOverflow, the issue was solved following the steps described in this GitHub comment:
<preference name="AndroidLaunchMode" value="singleTop" />
platforms/android/
ionic cordova prepare android
Seems that the issue is caused by the installation of cordova-plugin-background-mode
plugin, which I'm using too.
Fixed Issue by : Add the following line to your config.xml
:
< preference name="AndroidLaunchMode" value="singleTop" />
Note : Please check App if you use Appsflyer onelink for deeplinking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With