install / uninstall APKs programmatically (PackageManager vs Intents)

后端 未结 10 2145
时光取名叫无心
时光取名叫无心 2020-11-22 13:53

My application installs other applications, and it needs to keep track of what applications it has installed. Of course, this could be achieved by simply keeping a list of i

10条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 14:16

    If you're using Kotlin, API 14+, and just wish to show uninstall dialog for your app:

    startActivity(Intent(Intent.ACTION_UNINSTALL_PACKAGE).apply {
        data = Uri.parse("package:$packageName")
    })
    

    You can change packageName to any other package name if you want to prompt the user to uninstall another app on the device

提交回复
热议问题