How to check programmatically if an application is installed or not in Android?

后端 未结 15 1254
悲哀的现实
悲哀的现实 2020-11-22 05:51

We have installed applications programmatically.

  1. If the application is already installed in the device the application is open automatically.
  2. Otherwis
15条回答
  •  执念已碎
    2020-11-22 06:31

    Check App is installed or not in Android by using kotlin.

    Creating kotlin extension.

    fun PackageManager.isAppInstalled(packageName: String): Boolean = try {
            getApplicationInfo(packageName, PackageManager.GET_META_DATA)
            true
        } catch (e: Exception) {
            false
        }
    

    Now, can check if app is install or not

    if (packageManager.isAppInstalled("AppPackageName")) {
        // App is installed
    }else{
        // App is not installed
    }
    

提交回复
热议问题