尽可能简洁:尝试从安卓应用程序toprogrammatically安装APK时解析错误
-APK文件未损坏。
- 我可以浏览到手机文件系统中的APK,并从那里手动安装它,没有问题。
-I使用以下代码启动安装过程。文件的位置是正确的证实:
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'指向? – CommonsWare
'downloadfilelocation'您在日志中获取的路径是否正常? – Vikrant
是的,位置很好。它指向file:///storage/sdcard0/Download/org.mycompany.myapp.apk –