Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

Can't select imagem from Camera in Android - Always "canceled"

$
0
0

@franzisk4sis wrote:

I have this problem, every time I try select a picture straight from the Camera I always get an error "Camera cancelled.".

The scenario: my user can select between get the picture from the Camera or Gallery, when the picture comes from the gallery everything works fine, but when it comes from Camera always go to the "error" function and prints that message on console.

The problem happens after selecting the area to cut and press button "Save" on camera app on Android.

Here is my code in the controller to get the picture and set on an image tag:

var openCamera = function(source){
var _sourceType = source===1 ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA;
var options = {
    quality: 50,
    destinationType: Camera.DestinationType.DATA_URL,
    // destinationType: Camera.DestinationType.FILE_URI,
    sourceType: _sourceType,
    allowEdit: true,
    encodingType: Camera.EncodingType.PNG,
    targetWidth: 180,
    targetHeight: 220,
    cameraDirection: 1, //Back = 0, Front-facing = 1
    popoverOptions: CameraPopoverOptions,
    saveToPhotoAlbum: false,
    correctOrientation:true
};

$cordovaCamera.getPicture(options).then(function(imageData) {
    savePicture(imageData);
}, function(err) {
    // Every time I get the picture directly from the camera it comes here
    $scope.profileImageData = APP_CONST.DEFAULT_IMG_DATA;
    console.log(JSON.stringify(err));
});

}; // openCamera

The config:

app.config(function($compileProvider){
    $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|geo|mailto|tel|chrome-extension):/);
    $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|blob|content):|data:image\//);
})

Any help please?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles