我从Intel XDK NEW开始,我的应用程序需要从我的服务器下载一些PDF文件。
我已经按照API示例(http://software.intel.com/en-us/node/492847)进行了操作。 “更新”功能工作并显示进度,但“完整”功能永远不会被触发,文件永远不会被存储。
“更新”功能:
function cacheUpdated(evt) {
var outString = "";
outString += "current bytes downloaded: " + evt.current;
outString += " total bytes in download: " + evt.total;
var percentage = evt.current/evt.total
outString += " percentage downloaded: " + percentage + "%";
outString += " the unique id is: " + evt.id ;
outString += "the URL is: " + evt.url;
console.log(outString);
}
“完整”功能:
function cacheComplete(evt) {
var outString = "";
outString += "The procedure succeeded (" + evt.success + ") ";
outString += " the unique id is: " + evt.id ;
outString += "the URL is: " + evt.url;
alert(outString);
}
开始下载:
function downloadFile() {
intel.xdk.cache.addToMediaCacheExt("http://192.168.1.101/apostilas/57/1/apostila1.pdf",
Math.random()*100000);
document.addEventListener("intel.xdk.cache.media.update", cacheUpdated, false);
document.addEventListener("intel.xdk.cache.media.add", cacheComplete, false);
}
我做错了吗?
编辑:问题出在模拟器上;这在设备上运行良好。