2016-07-22 129 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 

如果您有任何疑問,請隨時與我聯繫。

相關問題