在 Android 上以编程方式安装应用程序 [英] Install Application programmatically on Android
本文介绍了在 Android 上以编程方式安装应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否可以从自定义 Android 应用程序以编程方式安装动态下载的 apk.
I'm interested in knowing if it is possible to programmatically install a dynamically downloaded apk from a custom Android application.
推荐答案
您可以轻松启动市场链接或安装提示:
You can easily launch a market link or an install prompt:
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///path/to/your.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);
Intent goToMarket = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("market://details?id=com.package.name"));
startActivity(goToMarket);
但是,您不能在没有用户明确许可的情况下安装 .apks;除非设备和您的程序已植根.
However, you cannot install .apks without user's explicit permission; not unless the device and your program is rooted.
这篇关于在 Android 上以编程方式安装应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文