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

后端 未结 15 1065
悲哀的现实
悲哀的现实 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:32

    The above code didn't work for me. The following approach worked.

    Create an Intent object with appropriate info and then check if the Intent is callable or not using the following function:

    private boolean isCallable(Intent intent) {  
            List list = getPackageManager().queryIntentActivities(intent,   
            PackageManager.MATCH_DEFAULT_ONLY);  
            return list.size() > 0;  
    }
    

提交回复
热议问题