REQUEST_DELETE_PACKAGES, For Realz Now
One of the changes announced for Android 8.0 was that apps needed to hold
REQUEST_DELETE_PACKAGES permission to be able to delete apps
ACTION_UNINSTALL_PACKAGE, once their
targetSdkVersion rose to 26 or higher.
It didn’t work, as apps
ACTION_UNINSTALL_PACKAGE even without holding this permission.
Now, on P Developer Preview 1, this actually works as (currently) documented. Once your
app has a
'P' (or, presumably, 28 or higher), you
need to have a
<uses-permission> element for
in order to be able to use
ACTION_UNINSTALL_PACKAGE. Without it, you get
an error in LogCat:
E/UninstallerActivity: Uid 10145 does not have android.permission.REQUEST_DELETE_PACKAGES or android.permission.DELETE_PACKAGES
Note that this error does not come from your process, so it will not show
up in LogCat if you are filtering for the selected app. There is no exception
thrown, either – from your app’s standpoint, your
startActivity() call is
just fine. However, the user is not presented with the “do you want to uninstall
this app?” dialog.
REQUEST_DELETE_PACKAGES is a
normal permission, so you do not need to mess
around with runtime permissions to hold it.
So, if you use
ACTION_UNINSTALL_PACAKGE (or equivalent methods), you’ll need
to add a line to your manifest for it to keep working.