[英]Ionic cordova-plugin-camera crash the application after take picture
I have an Ionic application that uses cordova-plugin-camera: 4.1.0 version, In a Redmi with Android version 9 and MIUI version 11.0.3, it doesn't work.我有一个使用 cordova-plugin-camera: 4.1.0 版本的 Ionic 应用程序,在带有 Android 版本 9 和 MIUI 版本 11.0.3 的 Redmi 中,它不起作用。 I can open the camera and click the picture but after that app crashes and restart this app.
我可以打开相机并单击图片,但在该应用程序崩溃并重新启动该应用程序之后。 Please suggest a better solution to solve it.
请提出更好的解决方案来解决它。
On Android 11 Ionic4 Camera leads to crash/ restart the application.在 Android 11 Ionic4 摄像头导致应用程序崩溃/重新启动。
My solution which worked for me after is that to allowEdit:false Here is my complete config code之后对我有用的解决方案是allowEdit:false这是我的完整配置代码
options: CameraOptions = {
quality: 30,
correctOrientation: true,
allowEdit: false,
targetWidth: 400,
targetHeight: 600,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
galleryOptions: CameraOptions = {
quality: 30,
correctOrientation: true,
allowEdit: false,
targetWidth: 400,
targetHeight: 600,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
cordova 7 not supporting new android sdk, you should use cordova 10 or like me drop the cordova plugin and make use of capacitor camera instead: cordova 7 not supporting new android sdk, you should use cordova 10 or like me drop the cordova plugin and make use of capacitor camera instead:
call this.backgroundMode.enable() just before this.camera.getPicture method and disable it before resolving.在 this.camera.getPicture 方法之前调用 this.backgroundMode.enable() 并在解析之前禁用它。
Make sure to add BackgroundMode in Providers array and import it in your component.确保在 Providers 数组中添加 BackgroundMode 并将其导入到您的组件中。 Follow
跟随
https://ionicframework.com/docs/native/background-mode https://ionicframework.com/docs/native/background-mode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.