Skip to content

Instantly share code, notes, and snippets.

@0xnbk
Created May 31, 2012 04:58
Show Gist options
  • Save 0xnbk/2841152 to your computer and use it in GitHub Desktop.
Save 0xnbk/2841152 to your computer and use it in GitHub Desktop.
Android Phonegap
function capture() {
// Retrieve image file location from specified source
navigator.camera.getPicture(getImageURI, function(message) {
alert('Image Capture Failed');
}, {
quality : 40,
destinationType : Camera.DestinationType.FILE_URI
});
}
function getImageURI(imageURI) {
var gotFileEntry = function(fileEntry) {
alert("got image file entry: " + fileEntry.fullPath);
var gotFileSystem = function(fileSystem) {
fileSystem.root.getDirectory("TestFolder", {
create : true
}, function(dataDir) {
// copy the file
fileEntry.moveTo(dataDir, "1.jpg", null, fsFail);
}, dirFail);
};
// get file system to copy or move image file to
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem,
fsFail);
};
// resolve file system for image
window.resolveLocalFileSystemURI(imageURI, gotFileEntry, fsFail);
// file system fail
var fsFail = function(error) {
alert("failed with error code: " + error.code);
};
var dirFail = function(error) {
alert("Directory error code: " + error.code);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment