One of the changes announced for Android 8.0 was that apps needed to hold
the REQUEST_DELETE_PACKAGES permission to be able to delete apps
using ACTION_UNINSTALL_PACKAGE, once their targetSdkVersion rose to 26 or .

It didn’t work, as apps
could use ACTION_UNINSTALL_PACKAGE even without holding this permission.

Now, on P Developer Preview 1, this actually works as (currently) documented. Once your
has a targetSdkVersion of 'P' (or, presumably, 28 or higher), you
need to have a <uses-permission> element for REQUEST_DELETE_PACKAGES
in 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
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 to your manifest for it to keep working.

Need a speaker at your Android development meetup? Mark Murphy is available, in person in the Boston/Pittsburgh/DC triangle, or by remote anywhere in the world! Contact Mark for details!


Source link
thanks you RSS link


Please enter your comment!
Please enter your name here