以编程方式卸载 android 应用程序 [英] unistall android application programmatically

查看:52
本文介绍了以编程方式卸载 android 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够允许我的用户从我的应用程序中卸载应用程序.就像 Google Play 商店允许他们的用户一样(请在下图)

I want to be able to allow my users to uninstall application from my application. Just like what Google Play Store allow to their users(Please below image)

主要问题是如何定义一个按钮,通过按下它我们可以通过提供程序包名称或其他一些信息来卸载应用程序.就像图像上的卸载按钮一样.

the main question is that how can define a button that by pressing it we can uninstall an app by giving the package name or some other info.Just like the uninstall button on the image.

推荐答案

try

Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:app package name"));
startActivity(intent);

如果这不起作用,那么将意图更改为:

If this doesn't work then change intent to:

Intent.ACTION_UNINSTALL_PACKAGE); 

并将数据类型设置为:

intent.setDataAndType(Uri.parse("package:" + your app package name));

这篇关于以编程方式卸载 android 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆