1
我用这个代码从我的本地安卓科尔多瓦应用触发更新程序
function downloadApkAndroid(data) {
var fileURL = "cdvfile://localhost/persistent/path/to/Download/";
var fileTransfer = new FileTransfer();
var uri = encodeURI(data);
fileTransfer.download(
uri,
fileURL,
function (entry) {
console.log("download complete: " + entry.fullPath);
promptForUpdateAndroid(entry);
},
function (error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false,
{
}
);
}
我得到了成功donwload然后它会调用这个函数promptForUpdateAndroid(entry);
尝试安装下载的APK这其中功能包含此
function promptForUpdateAndroid(entry) {
console.log(entry);
window.plugins.webintent.startActivity({
action: window.plugins.webintent.ACTION_VIEW,
url: entry.toURL(),
type: 'application/vnd.android.package-archive'
},
function() {
},
function() {
alert('Failed to open URL via Android Intent.');
console.log("Failed to open URL via Android Intent. URL: " + entry.fullPath);
}
);
}
它调用该函数后,我得到警报
解析错误 - 有解析包时出现问题
我认为是指定fileurl var fileURL = "cdvfile://localhost/persistent/path/to/Download/";
是错误的,但我真的不知道什么是真正的路径是。请帮我
我发现从这里的服务器下载的文件///data/user/0/com.app.nEnhance/files/files/path/to/android.apk当我尝试点击安装我得到了同样的错误,这是解析错误.. –