How can I get the package name of the current launcher in android 2.3 and above? How can I get the package name of the current launcher in android 2.3 and above? android android

How can I get the package name of the current launcher in android 2.3 and above?


I think you should be able to use PackageManager.resolveActivity(), with the home intent.

Intent intent = new Intent(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_HOME);ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);String currentHomePackage = resolveInfo.activityInfo.packageName;


in general, I agree to @JesusFreke using the PM resolveActivity

Intent intent = new Intent(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_HOME);ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);

but to get the right package name, you should use

resolveInfo.loadLabel(packageManager).toString()

or

resolveInfo.activityInfo.applicationInfo.loadLabel(packageManager).toString()

Hint:if there is no default set, this might become "Android System" or "open" as for the general System Intent Receiver

Hint:if you're looking for web browsers, you might use net.openid.appauth.browser.BrowserSelector#select() (0.7.1+) to implicit get the default browser even there is no one explicit set.