The old way of uninstalling android apps with ACTION_UNINSTALL_PACKAGE
is deprecated in API level 29. Now it's recommended to use PackageInstaller.uninstall(packageName: String, statusReceiver: IntentSender)
instead. This is what a came-up with so far:
fun uninstal(){
val packageName = "some package name"
val packageInstaller = this.packageManager.packageInstaller
val intent = Intent(this, this::class.java)
val sender = PendingIntent.getActivity(this, 0, intent, 0)
packageInstaller.uninstall(packageName, sender.intentSender)
}
I cannot figure out how to provide the IntentSender
. I tried to make an intent from and to the current activity but all this code does is recreate the activity. Any idea please? and thanks