Android上的Ionic Cordova相机插件错误 [英] Ionic Cordova camera plugin error on Android

查看:248
本文介绍了Android上的Ionic Cordova相机插件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Cordova版本是:6.3.0

Cordova version is: 6.3.0

Cordova Android版本是:5.0.0

Cordova Android version is: 5.0.0

相机插件版本:cordova-plugin-camera 2.2.0相机

Camera Plugin version: cordova-plugin-camera 2.2.0 "Camera"

我的代码适用于Android 5.0和Android 6.0的多台设备,但它不支持Android 4.4,Android 4,3等。

My code works on multiple devices with Android 5.0 and Android 6.0 but it does not working on Android 4.4, Android 4,3 etc.

在Android 4.4和4.3相机插件中触发相机和库但它没有进入.then(function(ImageData){..}它进入错误功能。

In Android 4.4 and 4.3 camera plugin triggers both camera and library but it does not get into .then(function(ImageData){..} it goes into error function.

    $scope.gallery = function() {
var options = {
        quality : 80,
        destinationType : Camera.DestinationType.DATA_URL,
        sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
        allowEdit : false,
        encodingType: Camera.EncodingType.JPEG,
        popoverOptions: CameraPopoverOptions,
        targetWidth: 500,
        targetHeight: 500,
        saveToPhotoAlbum: true,
        correctOrientation: true
    };
     $cordovaCamera.getPicture(options).then(function(imageData) {
          console.log('image'); 
          imaged = imageData;

          $scope.statusMessagePhoto = "photo saved ✓";
     }, function(error) {
            console.log(error.message);
       alert(error.message);
     });
};
$scope.savephoto = function(){
    var options = {
        quality : 80,
        destinationType : Camera.DestinationType.DATA_URL,
        sourceType : Camera.PictureSourceType.CAMERA,
        allowEdit : false,
        encodingType: Camera.EncodingType.JPEG,
        popoverOptions: CameraPopoverOptions,
        targetWidth: 500,
        targetHeight: 500,
        saveToPhotoAlbum: true,
        correctOrientation: true
    };
     $cordovaCamera.getPicture(options).then(function(imageData) {

          imaged = imageData;

          $scope.statusMessagePhoto = "photo saved ✓";
     } , function(error) {
            console.log(error.message);
       alert(error.message);
     });
};

当我按下savephoto按钮时相机打开,但在控制台(日志)中我收到错误undefined甚至在保存或选择我想要的照片之前也提醒。

When i press savephoto button camera opens, but in console (log) i get the error "undefined" and the alert too, before even save or choose the photo i want.

在Android 4.3或4.4上有任何人遇到过相同的错误。我重复该代码在Android 5.0及更高版本上运行完美。

Have anyone experienced the same error on Android 4.3 or 4.4. I repeat the code works perfect on Android 5.0 and above.

推荐答案

已解决!

从config.xml中删除此行

remove this line from config.xml

  <preference name="AndroidLaunchMode" value="singleInstance"/>

这篇关于Android上的Ionic Cordova相机插件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆