我正在使用 navigator.camera.getPicture api 调用的以下代码:
function getImageURI(imageURI) {
//resolve file system for image to move.
window.resolveLocalFileSystemURI(imageURI, gotPicture, function(error) {onfail(error,'Get Target Image');});
function gotPicture(targetImg) {
//move the image into the post_(n) directory.
targetImg.moveTo(Globals.POSTDIR_OBJ,Utils.getImageName(), moveSuccess2, function(error){alert('Move Error')} );
function moveSuccess2(){
alert('addPicture moveSuccess');
//update the picture counts in the client and DB.
Globals.pictCount++;
updateFilesById();
setTimeout("Gallery.show()",500);
};
}; //gotPicture
}; //getImageURI
问题是大约 30% 的时间没有调用成功或失败回调函数。
移动其实每次都是成功的,但是成功函数执行失败的时间大约有1/3。