我有一个使用cordova-plugin-camera的离子应用程序:4.1.0版本,在Android版本9和MIUI版本11.0.3的Redmi中,它不工作。我可以打开相机并点击图片,但在该应用程序崩溃后,重新启动此应用程序。请提出更好的解决方案来解决它。
r9f1avp51#
在Android 11 Ionic 4相机导致崩溃/重启应用程序。
我的解决方案是 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 }
xytpbqjk2#
cordova 7不支持新的android sdk,你应该使用 cordova 10或像我一样下降 cordova 插件,并利用电容相机代替:capacitor camera doc
fcy6dtqo3#
在这个. camera.getPicture方法之前调用这个. backgroundMode.enable(),并在解析之前禁用它。确保在Providers数组中添加BackgroundMode并将其导入到组件中。https://ionicframework.com/docs/native/background-mode
3条答案
按热度按时间r9f1avp51#
在Android 11 Ionic 4相机导致崩溃/重启应用程序。
我的解决方案是 allowEdit:false 以下是我的完整配置代码
xytpbqjk2#
cordova 7不支持新的android sdk,你应该使用 cordova 10或像我一样下降 cordova 插件,并利用电容相机代替:
capacitor camera doc
fcy6dtqo3#
在这个. camera.getPicture方法之前调用这个. backgroundMode.enable(),并在解析之前禁用它。
确保在Providers数组中添加BackgroundMode并将其导入到组件中。
https://ionicframework.com/docs/native/background-mode