fuunction createDownload(){
var dtask = plus.downloader.createDownload(downloadApkUrl, {filename: '_doc/download/'});
dtask.addEventListener("statechanged", function(task, status){
var downloadedSize = 0,
totalSize = 0,
pre = 0;
switch(task.state){
case 1:
console.log('开始下载...');
break;
case 2:
console.log('连接服务器...');
$("#loaded").show();
mui("#progressbar").progressbar().show();
break;
case 3:
totalSize = returnSize(task.totalSize);
downloadedSize = returnSize(task.downloadedSize);
$("#progressText").text(downloadedSize + "M / " + totalSize + 'M');
pre = parseInt((downloadedSize/totalSize)*100);
mui("#progressbar").progressbar().setProgress(pre);
break;
case 4:
installWgt(task.filename);
break;
}
}, false);
dtask.start();
}
function installWgt(path){
plus.runtime.install(path, {}, function(){
plus.nativeUI.alert("应用更新完成!", function(){
plus.runtime.restart();
});
}, function(DOMException){
plus.nativeUI.alert(JSON.stringify(DOMException));
});
//plus.runtime.openFile(path);
}
如果使用wgt文件更新可以安装成功
但是使用apk文件就提示读取文件失败,求大神告知
0 个回复