0

I'm trying to list all apps in android device with queryIntentActivities method but the list doesn't return all the apps , It returns only three of them. Here is my code:

    PackageManager packageManager = getPackageManager();

    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    List<ResolveInfo> allApps = packageManager.queryIntentActivities(intent, 0);
    for (ResolveInfo ri : allApps) {
        Log.d("Labels", String.valueOf(ri.loadLabel(packageManager)));
    }

is there anyone now why it returns only 3 applications ?

  • https://proandroiddev.com/how-to-get-users-installed-apps-in-android-11-b4a4d2754286 – NehaK Jan 08 '21 at 13:15
  • does this (https://stackoverflow.com/questions/2695746/how-to-get-a-list-of-installed-android-applications-and-pick-one-to-run) help? – icecube Jan 08 '21 at 13:15

1 Answers1

0

You are most likely trying to do this on Android 11. Make sure you add the <uses-permission android:name"android.permission.QUERY_ALL_PACKAGES"> permission to the AndroidManifest.xml file.

While I haven't tested this aspect of R DP2 yet, it appears that your app now can't find out what other apps are installed, on a general basis. The cited example is queryIntentActivities(), but to make this really work you would need to seriously lobotomize PackageManager. You can whitelist certain packages and certain structures to try to get by this for certain use cases. And, this is where the mysterious QUERY_ALL_PACKAGES permission seen in DP1 comes into play — this permission removes these new restrictions. Given the "look for Google Play to provide guidelines for apps that need this permission" caveat, it is safest to assume that if you try using it, eventually you will be banned from the Play Store by a bot.

snorlax
  • 2,197
  • 1
  • 13
  • 21