How to get list of installed application? Target SDK 32

Viewed 31

Is it possible to get full list of installed application on phone? I've added to my manifest (but QUERY_ALL_PACKAGES is underlined in red)

 <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
 <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

I've also added:

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
               if(context?.packageManager?.canRequestPackageInstalls() == true) {
                   val list = context?.packageManager?.getInstalledApplications(PackageManager.GET_META_DATA)
                   if(list != null) {
                       list.forEach {
                           Log.d("test list", it.packageName.toString())
                       }
                   } else {
                       Log.d("test", "list is null" )
                   }
               } else {
                   Log.d("test", "can not request")
               }
            }

But every time I get can not request. TargetSdk for my app is set on 32. I know about changes in Android 11 so my question is it still possible?

0 Answers
Related