API 级别 29 已弃用旧的卸载 android 应用程序的方法ACTION_UNINSTALL_PACKAGE
。现在建议PackageInstaller.uninstall(packageName: String, statusReceiver: IntentSender)
改用。到目前为止,这是一个想法:
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)
}
我无法弄清楚如何提供IntentSender
. 我试图在当前活动中创建一个意图,但是这些代码所做的只是重新创建活动。请问有什么想法吗?谢谢