Issue
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:
- Cordova 8.0
- cordova-android 6.4.0
- cordova-plugin-camera 4.0.2
Have tried this solution, but getting the same result. So, how can I solve this issue? Am I forgetting something?
Thanks for the help.
Solution
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:
- Add the following line to your config.xml:
<preference name="AndroidLaunchMode" value="singleTop" />
- Remove the directory
platforms/android/
- Run
ionic cordova prepare android
Seems that the issue is caused by the installation of cordova-plugin-background-mode
plugin, which I'm using too.
Answered By - Bruno Peres
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.