本文介绍了安装APK与Intent.ACTION_VIEW正在下载但不安装文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 乌里myUrl = Uri.parse(stringURL);
意图UPDATE1 =新意图(Intent.ACTION_VIEW).setData(myUrl);
startActivity(UPDATE1);

这使得apk文件的下载,但下载安装后不会启动。你需要通过点击下载在通知栏完成手动启动它。这也是在大多数论坛答案溶液

 乌里myUrl = Uri.parse(stringURL);
意图UPDATE2 =新意图(Intent.ACTION_VIEW).setDataAndType(myUrl,应用程序/ vnd.android.package归档);
startActivity(UPDATE2);

在这种情况下,我得到的消息(DDMS):无活动处理的意图......我也认为MIME应用/ vnd.android.package归档,是不是强制性的。这是真的?
如果没有,你必须配置HTTP服务器,使这项工作。
像.htaccess文件需要与被更新:

If is it so, do you know any link of apk that i can test, if after download, installation process starts automatically (files on this site are not samples installed).

Is any workaround that I can call install intent from code?

解决方案

I am not aware that this is possible.

You can download the file yourself, then do an ACTION_VIEW Intent on the local APK file. That, AFAIK, will immediately bring up the installation screen.

这篇关于安装APK与Intent.ACTION_VIEW正在下载但不安装文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 10:16
查看更多