SoFunction
Updated on 2025-04-10

Android Get the list of installed applications on your phone in detail

1. Scan the installed application list

var queryIntentActivities = mutableListOf<ResolveInfo>()
        val intent = Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
        if (.SDK_INT >= .VERSION_CODES.M) {
            queryIntentActivities =
                (intent, PackageManager.MATCH_ALL)
        } else {
            queryIntentActivities = (intent, 0)
        }

In the above code, queryIntentActivities is the application list data obtained.

Traversal to obtain information about each application

Next, we will directly obtain the information of each application through traversal.

 {
            bean = AppInfoBean(
                icon = (packageManager),
                appName = (packageManager).toString(),
                appPackageName = 
            )
            (bean!!)
        }

The above AppInfoBean is an entity bean defined by itself. It contains the application name, package name, and Drawable type application icon.
appBeanList is a defined list variable.

Note: Here is a reminder, which is also a small problem I encountered. When scanning all applications, the Intent action is: Intent.ACTION_MAIN Remember, otherwise no one will be found.

Add permissions

Also, there may be only a few application lists you get from above, which is not complete. At this time, you need to add a permission:

<uses-permission
        android:name=".QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />

With the above permission, you can get all the applications

Query the icon of the corresponding application through the package name icon

    /**
      * Check the icon image of the application according to the application package name
      */
    private fun loadAppIconByPackageName(packageName:String,listener:(icon:Drawable) -&gt; Unit){
        try {
            if (packageManager == null){
                packageManager = 
            }
            val packageInfo = packageManager?.getPackageInfo(
                packageName,
                PackageManager.GET_ACTIVITIES
            )
            packageInfo?.applicationInfo?.loadIcon(packageManager)?.let { (it) }
        } catch (e: Exception) {
            ((.ic_launcher))
        }
    }

This is simple. You can get the current packageManager by getting the corresponding icon. However, this is the same as the above acquisition application, and requires permissions and otherwise you may encounter problems that cannot be scanned.

Get the full class name of the startup page of the corresponding application through the package name

/**
   * Get the app's entry activity through the package name
   */
 @SuppressLint("WrongConstant")
 fun getAppEnter(context: Context, packageName: String): String {
     var mainAct = ""
     try {
         val intent = Intent().apply {
             action = Intent.ACTION_MAIN
             addCategory(Intent.CATEGORY_LAUNCHER)
         }
         val list =
             (intent, PackageManager.GET_ACTIVITIES)
          {
             if ((, packageName)) {
                 mainAct = 
             }
         }
     } catch (ex: Exception) {
     } finally {
         return mainAct
     }
 }

This thing to note is the same as the first app list, and there is nothing else to pay attention to.

The above is the detailed explanation of Android's application list that has been installed on your phone. For more information about Android's application list, please follow my other related articles!