To Check if a package is installed in android Kotlin programmatically for android 12 . Without declaring a query in the manifest file for Android 12 (API 31 ).
CodePudding user response:
private fun isAvailable(ctx: Context, intent: Intent?): Boolean {
val mgr = ctx.packageManager
val list = mgr.queryIntentActivities(intent!!, PackageManager.MATCH_DEFAULT_ONLY)
return list.size > 0
}
Use this code snippet for that, Thanks.