Created
May 31, 2012 04:58
-
-
Save 0xnbk/2841152 to your computer and use it in GitHub Desktop.
Android Phonegap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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