2016-07-22 26 views
0

我正在为我的离子应用程序使用相机插件。 当我尝试设备上的浏览器应用程序时,相机正在工作,但是当我在我的设备上构建并运行APK时,getPicture方法未被触发。科尔多瓦相机无法正常工作时,为Android构建应用程序

$scope.takePictureBack = function() { 
      $ionicPlatform.ready(function() { 
       var cameraOptions = { 
        quality: 100, 
        targetHeight: 1080, 
        targetWidth: 1920, 
        destinationType: Camera.DestinationType.DATA_URL 
       }; 
       var success = function (data) { 
        $scope.$apply(function() { 
         /* 
         remember to set the image ng-src in $apply, 
         i tried to set it from outside and it doesn't work. 
         */ 
         $scope.cameraPicBack = "data:image/jpeg;base64," + data; 
        }); 
       }; 
       var failure = function (message) { 
       }; 
       //call the cordova camera plugin to open the device's camera 
       navigator.camera.getPicture(success, failure, cameraOptions); 
      }) 
     }; 

我已经尝试过使用日志进行测试,并且似乎无法达到失败回调或方法的成功回调。

有没有人知道相机插件的任何并发症。 为了记录我的科尔多瓦和离子被更新,并且我正在使用Android 6.0.1在Galaxy s6 edge上进行测试。

回答

0

请使用此代码我测试了它在Android设备上。它根据您的需要工作。简单地说,您必须增加相机选项。这里是选项。

  quality: 75, 
      destinationType: Camera.DestinationType.DATA_URL, 
      sourceType: Camera.PictureSourceType.CAMERA, 
      allowEdit: true, 
      encodingType: Camera.EncodingType.JPEG, 
      targetWidth: 300, 
      targetHeight: 300, 
      popoverOptions: CameraPopoverOptions, 
      saveToPhotoAlbum: false 

如果您有任何疑问,请随时与我联系。

相关问题