在我的应用程序中我尝试使用PhoneGap拍照,但是我收到了失败的消息,当我谷歌消息我得不到结果。我可以拍一张照片然后我收到消息
这里是我的代码,当我选中按钮时:
onBtnPhotoUmgebungTap: function(button, e, eOpts) {
var pictureSource;
var destinationType;
console.log('here 1');
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log('here 2');
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
quality : 50,
destinationType : destinationType.DATA_URL
})
}
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64 encoded image data
var date = ""
var d = new Date();
date = "" + d.getDate() + "-" + (d.getMonth() + 1) + "-"
+ d.getFullYear();
console.log('here 3');
alert(date)
//alert(imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
console.log('here 4');
console.log('smallimage:'+smallImage)
//
smallImage.style.display = 'block';
console.log('here 5');
// Show the captured photo
// The inline CSS rules are used to resize the image
smallImage.src = "data:image/jpeg;base64," + imageData;
console.log('here 6');
alert("data:image/jpeg;base64," + imageData)
console.log('here 7');
//This part is for saving the capture photo
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
function gotFS(fileSystem) {
alert("image/" + date + ".jpeg")
fileSystem.root.getFile("image/" + date + ".jpeg", {
create : true,
exclusive : false
}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
var data = "data:image/jpeg;base64," + imageData;
writer.write(data);
}
function fail(error) {
alert("error")
console.log(error.code);
}
}
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
// console.log(imageURI);
// Get image handle
var largeImage = document.getElementById('largeImage');
// Unhide image elements
// largeImage.style.display = 'block';
console.log('here 9');
// Show the captured photo
// The inline CSS rules are used to resize the image
//
largeImage.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}},
这里是失败的消息:
processMessage failed:消息:S01 Camera1533883342 + URI
我希望有人能帮助我
感谢问候