【发布时间】:2017-01-16 12:37:34
【问题描述】:
尽量简洁:
-APK 文件没有损坏。
-我可以浏览到手机文件系统中的 APK 并从那里手动安装它而不会出现问题。
-我正在使用以下代码来启动安装过程。文件位置确认正确:
public void installfromlocal()
{
String downloadfilelocation = getsharedresourcestring("updatepackagelocation");
Log.e("installing from",downloadfilelocation);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(downloadfilelocation)), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
到目前为止,我可以从互联网上的几个小时收集到的是,显然我无法让我的应用程序以编程方式从外部存储安装 APK。我显然也不能将文件复制到内部存储并从那里安装。
那么现在呢?此外,我没有收到来自 Logcat 的消息。我只收到一个弹出窗口,提醒我解析 apk 时出错。
【问题讨论】:
-
downloadfilelocation指向究竟在哪里? -
downloadfilelocation你在日志中得到的路径好吗? -
是的,位置很好。它指向 file:///storage/sdcard0/Download/org.mycompany.myapp.apk
-
这里也一样。问题出现在 android 6 和 7。较低版本没问题(相同的 apk)
-
它在 4.4 和任何 Cyanogenmod 12 上为我完成。
标签: android apk android-install-apk