Home > Software design >  How to get a list of installed apps on Android device
How to get a list of installed apps on Android device

Time:02-17

I am trying to make a simple Android Launcher. Through a tutorial and some other stack overflow posts I found this method of getting the list of installed apps:

        Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        List<ResolveInfo> rawAppList = getApplicationContext()
                                        .getPackageManager()
                                        .queryIntentActivities( mainIntent, 0);

However, when I try to run this, I only get a list of 4 apps. The emulator I'm using to test has 14 apps displayed through the default launcher. Ideally, I would be able to see all of these in my own launcher.

I've tried cloning a git project which gets installed apps in the same way. When running it on the same emulator all 14 apps are retrieved as expected.

So clearly there's something I've done wrong, but I can't figure out what it is. As far as I can tell, the tutorial I watched has no extra steps. There doesn't seem to be any extra steps suggested in any of the other stack overflow posts I've seen either.

Can anyone spot what I'm doing wrong here?

CodePudding user response:

To comply with package visibility rules, you will need a <queries> element as a child of the root <manifest> element:

<queries>
    <intent>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.action.LAUNCHER" />
    </intent>
</queries>
  • Related