我是 PhoneGap Android 开发人员的新手。我正在使用 phonegap 在 android 中制作应用程序。我想从设备相机拍摄照片,然后我想在从设备拍摄图像后将其显示在屏幕上,并将拍摄的图像存储在 SD 卡中。你能告诉我怎么做吗?
古尔普雷特辛格
最佳答案
用于保存在SD卡中......
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);
}
关于javascript - PhoneGap - Android - 如何将相机拍摄的图像保存在 SD 卡中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9926152/