ボンジュール
Android 用のシンプルなマーケット アプリケーションを作成したいのですが、厄介な問題に直面しています。
インストールの流れは以下のとおりです。
1- アプリケーション コンテキストでの apk ファイルのダウンロード :
InputStream input = new BufferedInputStream(url.openStream()) ;
OutputStream output = openFileOutput("xx.apk", Activity.MODE_WORLD_READABLE);
byte data[] = new byte[1024];
while ((count = input.read(data)) != -1 && statusDownload ) {
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
2- ダウンロードが終了したら:
promptInstall = new Intent(Intent.ACTION_VIEW);
File fileApk = new File (getFilesDir() + "/xx.apk");
promptInstall.setDataAndType(Uri.fromFile(fileApk) , Consts.APK_FILE_INSTALL_TYPE);
startActivityForResult(promptInstall,654);
3- インストール後 (またはキャンセルした場合)、apk ファイルは削除されます。
File fileApk = new File (a.getFilesDir() + "/xx.apk" );
fileApk.delete();
apk ファイルをインストールするには、「誰でも読み取り可能」である必要があります。これは、ファイルをダウンロードした後 (およびインストールする前) に、誰もが apk ファイルを取得できることを意味します。
外部ダウンロードを回避するための適切なアクセス許可を設定する方法を知っている人はいますか?
読んでくれてありがとう !