编程删除我的应用程序(安卓)我的、应用程序

2023-09-05 11:29:01 作者:≠铁了心,才成刚。

我想卸载我的按钮,点击应用。为此,我现在用以下code。

I want to uninstall my application on button click. For this I am using following code.

Uri packageURI = Uri.parse("package:"+packageName);
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);

这给我造成的,但是我想直接删除不点击与消息对话框中的此应用程序将被卸载,确定按钮。

It gives me result, but I want to delete directly without click on "Ok" button of dialog with message "This application will be Uninstalled".

我只是想直接卸载应用程序。

I just want uninstalling application directly.

推荐答案

卸载而无需用户确认,不允许第三方应用程序。

Uninstalling without user confirmation is not allowed to 3rd party applications.

由于xDragonZ指出,根进程可以粗略地做到这一点,从字面上删除目录和离开软件包管理器处理的损失,但是这不是一个很广泛的部署的解决方案,因为AFAIK没有设备附带的能力的应用程序运行他们自己的根帮手的过程 - 这是一个危险的售后修改

As xDragonZ points out, a root process can crudely do this by literally removing the directory and leaving the package manager to deal with the loss, but that's not a very widely deployable solution, since AFAIK no devices ship with that capability for apps to run their own root helper process - that's a risky aftermarket modification.