Answer the question
In order to leave comments, you need to log in
How to work with camera in cordova?
Good time. For a week now I have been struggling with the problem of using the camera in a non-native application for android. I am using cordova as api.
Question. How to get a photo from the camera and then get the data url of this photo?
PS I tried to implement it using ngCordova, the camera opens, takes a picture, and then nothing.
Maybe someone has a working code, please share.
Answer the question
In order to leave comments, you need to log in
If we are talking about the plugin https://github.com/apache/cordova-plugin-camera.
The code from the documentation works for me:
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.DATA_URL
});
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question