简体   繁体   English

Ionic cordova-plugin-camera 在拍照后使应用程序崩溃

[英]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:

capacitor camera doc电容相机文档

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.

相关问题 ionic 4 cordova-plugin-camera 默认前置摄像头不适用于 android - ionic 4 cordova-plugin-camera default FRONT camera not Working on android Ionic Cordova-Plug-Camera在Android上的大问题 - Ionic cordova-plugin-camera big issue on Android Ionic 3:安装cordova-plugin-camera和Native Web-intent后,Android添加平台失败 - Ionic 3 : Android add platform fails after installing cordova-plugin-camera and Native Web-intent Ionic Cordova-Plug-Camera无法在Android上打开图库 - Ionic cordova-plugin-camera not opening gallery on Android 在离子框架和cordova-plugin-camera中,使用相机拍摄的照片在应用程序中逆时针旋转90度 - In ionic framework & cordova-plugin-camera pictures taken with camera are being rotated 90 degrees anti clockwise in app Cordova-plugin-camera 不适用于 Android 版本 8 - Cordova-plugin-camera not working with Android version 8 cordova-plugin-camera在Crosswalk Android上不起作用(在iOS上工作) - cordova-plugin-camera not working on Crosswalk Android (Works on iOS) Android Cordova-Plug-Camera在PNG上添加黑色背景 - android cordova-plugin-camera adds black background on PNG 如何显示图像<img>来自 cordova-plugin-camera - how to show image with <img> from cordova-plugin-camera 离子:每张照片/多张照片后相机要求确认 - Ionic: Camera asks confirmation after every picture / take multiple shots
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM