Can a package uninstall itself? Can a package uninstall another package if they share the same userId and signature?
-
Thks for asking... I know there are an third party app called easy uninstall that let you uninstall package so maybe we should look at the source. – Bite code May 21 '09 at 09:28
-
Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:"+supportModel.getPackageName())); intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(intent, UNINSTALL_REQUEST_CODE); – Abhishek Sharma Jun 09 '20 at 06:14
4 Answers
Uri packageURI = Uri.parse("package:"+"your.packagename.here");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);

- 18,333
- 31
- 67
- 74

- 1,211
- 11
- 9
A 3rd party app cannot install or uninstall any other packages programmatically, that would be a security risk for Android. However a 3rd party app can ask the Android OS to install or uninstall a package using intents, this question should provide more complete information:
install / uninstall APKs programmatically (PackageManager vs Intents)

- 1
- 1

- 13,927
- 5
- 80
- 123
Third Party app cannot Uninstall App Silently!
Either you need to become System App to get DELETE_PACKAGES Permission else you need to show Uninstall Popup (User Confirmation)
Alternatively, you can take Accessibility permission and then by showing an Accessibility Overlay you can tell your service to click on Uninstall button! But that will be privacy violation.

- 632
- 8
- 17
-
How do you uninstall privately in such a case? Being a system app and having the DELETE_PACKAGES permission doesn't help without the code. – Matan Koby Nov 28 '19 at 13:33
In Kotlin, using API 14+, you can just call the following:
startActivity(Intent(Intent.ACTION_UNINSTALL_PACKAGE).apply {
data = Uri.parse("package:$packageName")
})
Or with Android KTX:
startActivity(Intent(Intent.ACTION_UNINSTALL_PACKAGE).apply {
data = "package:$packageName".toUri()
})
It will show the uninstall prompt for your app. You can change packageName
to any package name of another app if needed.

- 10,965
- 2
- 39
- 58