可能です:
だから我々は最初の.apkファイルをダウンロードしようとしています。これにはファイル転送プラグインが必要です。 あなたは、次のコマンドでインストールすることができます。
phonegap local plugin add org.apache.cordova.file-transfer
を第二に、我々はwebintentを開始するために別のプラグインを必要としています。このWebintentは、更新があるかどうかをユーザーに確認します。あなたは、次のコマンドでインストールすることができます。
phonegap local plugin add https://github.com/Initsogar/cordova-webintent.git
次に、あなたがた.apkをダウンロードするには、アプリケーションの更新がある 場合、ユーザーに促すために、あなたのコード内でこの2つの機能を使用することができます。
/*
* Uses the filetransfer plugin
*/
function downloadApkAndroid(data) {
var fileURL = "cdvfile://localhost/persistent/CegekaMon.apk";
var fileTransfer = new FileTransfer();
var uri = encodeURI(data.android);
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,
{
}
);
}
/*
* Uses the borismus webintent plugin
*/
function promptForUpdateAndroid(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);
}
);
}
インストール後apkでphonegapを使用するにはどうすればそのapkを自動起動できますか? fileapiまたはwebintentプラグインに具体的な方法がありますか教えてください – nida
http://download.com/update/myapp.apkからアップデートをダウンロードしたいです。それではコードは何でしょうか?助けてください。あなたの答えは –