Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of every launcher in Android

In my application I want to show a list of every available launcher (for homescreen) on that specific Android phone. Is it possible to get some kind of information from Android OS and how do I make this call?

Thanks!

Kind regards Daniel

like image 341
Daniel Nord Avatar asked May 30 '11 11:05

Daniel Nord


2 Answers

You can query the list of ResolverInfo that match with a specific Intent. The next snippet of code print all installed launchers.

PackageManager pm = getPackageManager();
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
List<ResolveInfo> lst = pm.queryIntentActivities(i, 0);
for (ResolveInfo resolveInfo : lst) {
    Log.d("Test", "New Launcher Found: " + resolveInfo.activityInfo.packageName);
}
like image 188
Fede Avatar answered Oct 09 '22 00:10

Fede


The code snippet above does NOT work accurately, as the result of launchers' list also includes system's setting's app whose package name is com.android.settings. This unexpected result happens on both my Pixel 2 (Android 8.0 ) and Nexus 6 (Android 7.1).

like image 41
somard Avatar answered Oct 09 '22 02:10

somard