An application may have zero, one, or several activities that belong in a launcher. Hence, a launcher should not be asking "what are all the applications, and what is the launch Intent
for each?" A launcher should, instead, be asking "what are all of the activities that I should show?"
That is accomplished using PackageManager
and queryIntentActivities()
. This sample project implements a complete launcher. The key lines are:
PackageManager pm=getPackageManager();
Intent main=new Intent(Intent.ACTION_MAIN, null);
main.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> launchables=pm.queryIntentActivities(main, 0);
Then, you can use whatever mechanism you want to render that launchables
collection. The sample project puts them in a ListView
.