Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 9 Intent.ACTION_UNINSTALL_PACKAGE not working

On android pie, I want to call the package manager to uninstall my own app. Here is what I am trying:

val uri = Uri.parse("package:$packageName")
val uIntent = Intent(Intent.ACTION_UNINSTALL_PACKAGE, uri)
startActivity(uIntent)

Oddly this is not working. Nothing is being shown in the logcat as well.

I have also tried ACTION_DELETE

val uri = Uri.parse("package:$packageName")
val uIntent = Intent(Intent.ACTION_DELETE, uri)
startActivity(uIntent)

Please tell me what I am doing wrong. This seems a pretty straightforward job. Am I missing any permission or something I need to declare in manifest? Thanks.

like image 402
SayantanRC Avatar asked Sep 13 '25 17:09

SayantanRC


1 Answers

I was missing manifest permission.

<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>

This is probably required for Android 6.0 and above. The code in the question now works perfectly. Tested on Android 9 and Android 10.

like image 156
SayantanRC Avatar answered Sep 16 '25 07:09

SayantanRC