4

The only way I know of for uninstalling an application is by sending an intent (as described here), but this opens an activity for the user to confirm the uninstall.

I'm aware of the fact that there's no other way to uninstall other applications without user intervention (unless you have the DELETE_PACKAGES permission, which means you are the OEM).

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

2 Answers 2

5

There is a hidden function in PackageManager named deletePackage (it can be called via reflection). But it requires android.permission.DELETE_PACKAGES permission. It doesn't matter whether you are the owner of the app or not, you must have this permission granted. And this permission will not be granted to 3rd party apps.

So, basically, you can't uninstall application even if its yours. This actually makes sense, because user should be in control of such key events as installation and uninstallation of apps. Just imagine the frustration of user if he or she just installed the app from market but cann't find it (or similar scenarios).

You should just disable you application functionality with a proper message. This will be much more user-friendly.

Sign up to request clarification or add additional context in comments.

Comments

0

App installation and uninstalltion can be silently done if your app is configured as a device owner.

Device owner is introduced from android 5.0 onwards. Silent installation features were added from 6.0 onwards.

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 given to a rooted user, system app and a device owner.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.