$cordovaCapture: on android image gallery is opened instead of camera

I use $cordovaCapture for capturing images. The following code works perfect on iOS:

var options = {limit: 1};
$cordovaCapture.captureImage(options).then(
           function (imageData) {
                  //store image data...
           }, function (err) {
                    $log.log('error capturing image: ' + err);
           });

On iOS, I receive the imageData with file URI, which I can store and use for displaying the image.

But on android, instead of the camera, the gallery is opened. In order to activate the camera, I have then to cancel the gallery view. This opens the camera, but after taking the picture and quitting with ‘ok’, the promise is rejected (error function called).

Any idea, why it doesn’t work on android?


Additional information: I’ve just found out, that the problem on android exists only, if the capturing is triggered from a button on a $ionicActionSheet. If triggered directly from the <ion-content> element, everything works fine on android as well.
Is this rather a $ionicActionSheet issue than a $cordovaCapture issue?

The problem is solved. There was a bug in my code, I forgot the break keyword in a switch statement:

switch (index) {
    case 0:
        captureImage();
        break; // --> the forgotten break
    case 1:
        openImagePicker();
}

Thats why the image picker was always opened. On iOS the camera seemed to block the image picker, that’s why it worked on the iPhone.

EVERYTHING WORKS CORRECTLY!

nice, letting us know that you fixed the issue on your own :thumbsup:

Thanks for your support. It’s an amazing framework!!!