Search code examples
androidlauncherandroid-launcher

Selectively displaying apps in Android


i'm making a launcher app and i would like to know how to selectively display apps on my launcher based on user input. Like other launchers will show all the apps normally, but in my launcher the user can, if they want, choose not to show some apps.

So how would i call PackageManager to show/not show a few select apps?

My current way is-

  1. Query all apps from PackageManager and keep it in a <ResolveInfo> list
  2. Keep the apps not to show in another <ResolveInfo> list
  3. Subtract the lists and pass the new list to populate my launcher

I need help in step 3


Solution

  • You can use this code to compare user selected app to hide with installed app and generate new list to show in your launcher:

    List<PackageInfo> packageInfos=getPackageManager().getInstalledApplications();
        List<PackageInfo> newList=new ArrayList<>();
        for (PackageInfo packs:
             packageInfos) {
            if(!packs.packageName.equals("User input package name"))
                newList.add(packs);
        }