How to remove my own Android application without user intervention?

The only way I know to uninstall the application is to send the intent ( as described here ), but this opens up activity to confirm the uninstall.

I know that there is no other way to remove other applications without user intervention (if you do not have DELETE_PACKAGES permission, which means that you are OEM).

But is there a way to remove my own application without user intervention?

+4
source share
2 answers

PackageManager has a hidden function called deletePackage (it can be called via reflection). But this requires android.permission.DELETE_PACKAGES permission. It doesn’t matter whether you own the application or not, you must obtain this permission. And this permission will not be granted to third-party applications.

So basically, you cannot uninstall the application, even if it is yours. This really makes sense, as the user must control key events such as installing and uninstalling applications. Imagine a user’s frustration if he or she simply installed an application from the market but cannot find it (or similar scenarios).

You should simply disable the application functionality with the correct message. It will be much more convenient.

+5
source

Installation and removal of applications can be done without pauses if your application is configured as the owner of the device.

The device owner is introduced from Android version 5.0 onwards. Silent installation features have been added since version 6.0.

From andorid source:

 if ((mPm.checkUidPermission(android.Manifest.permission.INSTALL_PACKAGES, installerUid) == PackageManager.PERMISSION_GRANTED) || (installerUid == Process.ROOT_UID) || mIsInstallerDeviceOwner) { mPermissionsAccepted = true; } else { mPermissionsAccepted = false; } 

This privilege is granted to the root user, system application, and device owner.

0
source

All Articles