gpt4 book ai didi

android - 使用 Intent.ACTION_VIEW 安装 apk 正在下载但不安装文件

转载 作者:行者123 更新时间:2023-11-29 18:22:36 25 4
gpt4 key购买 nike

Uri myUrl = Uri.parse(stringURL); 
Intent update1 = new Intent(Intent.ACTION_VIEW).setData(myUrl);
startActivity( update1 );

这会启用 apk 文件的下载,但下载后安装不会开始。您需要通过单击通知栏中的下载完成来手动启动它。这也是大多数论坛答案中的解决方案。

Uri myUrl = Uri.parse(stringURL); 
Intent update2 = new Intent(Intent.ACTION_VIEW).setDataAndType(myUrl,"application/vnd.android.package-archive");
startActivity( update2 );

在这种情况下,我收到消息 (DDMS):找不到处理 Intent 的 Activity ...我还认为 MIME“application/vnd.android.package-archive”不是强制性的。这是真的?如果没有,您是否必须配置 http 服务器才能使其正常工作。比如 .htaccess 文件需要更新为:

AddType application/vnd.android.package-archive

如果是这样,你知道我可以测试的任何 apk 链接,如果下载后,安装过程会自动开始(此站点上的文件未安装 samples)。

有没有我可以从代码中调用安装 Intent 的解决方法?

最佳答案

do you know any link of apk that i can test, if after download, installation process starts automatically

我不知道这是可能的。

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

您可以自己下载文件,然后对本地 APK 文件执行 ACTION_VIEW Intent。据我所知,这将立即显示安装屏幕。

关于android - 使用 Intent.ACTION_VIEW 安装 apk 正在下载但不安装文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4552428/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com