Can a package uninstall itself? Can a package uninstall another package if they share the same userId and signature?
Can a package uninstall itself? Can a package uninstall another package if they share the same userId and signature?
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)
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.