Android でサーバーからアプリをダウンロードし、内部メモリに保存しています。
URLConnection connection = url.openConnection();
connection.connect();
// download the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(getFilesDir() + "/filename");
byte data[] = new byte[1024];
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
ダウンロードが完了すると、通知が表示されます。通知をクリックすると、アプリがインストールされます。
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(getFilesDir()+ "/filename")),"application/vnd.android.package-archive");
PendingIntent act = PendingIntent.getActivity(MainActivity._activity,0, i, 0);
notification.setLatestEventInfo("TEXT", "TEXT, act);
しかし、通知をクリックすると、「パッケージの解析中にエラーが発生しました」というダイアログ ボックスが表示されます。なんで?