Reputation: 2351
I'm new in PhoneGap Android developer. I'm making an application in android using the phonegap. I want to take picture from the device camera and then i want to display it on the screen after taking the image from device and as well as store that captured image in the SD Card. Can you please tell me how i can do this.
Gurpreet singh
Upvotes: 2
Views: 13692
Reputation: 5264
For saving in the SD card......
function save(){
document.addEventListener("deviceready", onDeviceReady, false);
}
// PhoneGap is ready
//
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("pic.jpg", {create: true, exclusive: false}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
var photo = document.getElementById("image");
writer.write(photo.value);
}
function fail(error) {
console.log(error.code);
}
Upvotes: 4
Reputation: 7659
Refer the following gist which does capture the image from camera in both data and file mode.
Reference from
Capture camera image - Phonegap Doc
Upvotes: 4