android: 错误解析包

标签 android parsing package

我正在从服务器下载 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);

但是当我点击通知时,会出现一个对话框:Error parsing package。为什么?

最佳答案

设备中可能已经安装了具有相同包名的另一个应用程序。所以你得到了错误。

关于android: 错误解析包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11538918/

相关文章:

android - 尝试使用 where 子句时内容解析器 .query 出现问题

parsing - Oracle 的 PL/SQL block 的语法图有错吗?

parsing - 以下设定程序

java - 如何从非资源文件中解析xml

R 包 - 文件 'zzz.R' 用于什么?

linux - 如何查找包含特定文件的包?

android - R.layout-land 无法解析为变量

android - avdmanager : Command failed with exit code 1 cordova

javascript - 如何将字符串转换为 React 组件

java - 简单的导入问题