-3

i am writing an android application that showing all installed applications and apps permissions. I am writing this app. using kotlin. Is there any way to get all installed applications from package manager I AM NOT USING JAVA.

3 Answers3

1

You can do something like this:

val packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA)

for (packageInfo in packages) {
    Log.d(TAG, "Package name:" + packageInfo.packageName)
}

You can also check this article to check how it works in Android 11:

https://proandroiddev.com/how-to-get-users-installed-apps-in-android-11-b4a4d2754286

Kunal Chaubal
  • 337
  • 3
  • 11
0
  val mainIntent = Intent(Intent.ACTION_MAIN, null)
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER)
    val pkgAppsList = context.packageManager.queryIntentActivities(mainIntent, 0)
The Dude
  • 347
  • 4
  • 11
0

Using the below snippet you can get details of the installed app on a device

val packages: List<ApplicationInfo> =
    pm.getInstalledApplications(PackageManager.GET_META_DATA)

for (packageInfo in packages) {
    Log.d(
       "log",
        "Installed package :" + packageInfo.packageName
    )
    Log.d("log", "Source dir : " + packageInfo.sourceDir)
    Log.d(
       "log",
        "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName)
    )
}

This is already answered the question here in java. I just convert that into kotlin in IDE

Code->Convert java file to Kotlin

It works fine

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
d-feverx
  • 1,424
  • 3
  • 16
  • 31