Cordova Camera Plugin does not trigger the return of success or failure

Asked

Viewed 89 times

1

I’m trying to use the latest version (2.2.0) of the Cordova Camera Plugin in an app I’m developing on Intel XDK. My javascript and HTML are:

<script type="text/javascript" charset="utf-8">
    function onSuccess(imageURI) {
        alert(imageURI);
        var image = document.getElementById('image');
        image.src = imageURI;
    }    
    function onFail(message) { alert('Failed because: ' + message); }

    function capturePhoto() {
        navigator.camera.getPicture(onSuccess, onFail, {
            destinationType: Camera.DestinationType.FILE_URI,
            mediaType: Camera.MediaType.PICTURE,
            saveToPhotoAlbum: true,
            sourceType: Camera.PictureSourceType.CAMERA            
        });
    }
</script>  

 

<button onclick="capturePhoto();">Capture Photo</button> <br>
<center>
    <img style="width:260px;height:260px;" id="image" src="" />
</center>

The camera opens normally, I take the photo and confirm that I will use it. But when it goes back to the application nor the function onSuccess nor the function onFail are executed. Photos are being saved successfully.

I’ve tried some things:
Do something with the Android event pipeline
Listen to the event resume

  • Friend, I performed the test here worked correctly. I took your code and added in my app.

  • I copied the code into http://github.com/gomobile/sample-image-capture and it worked, but I still haven’t identified why the above code didn’t work.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.