If my phone is installed 3-4 home(launcher) apps,when I press home key,it will show a dialog to display the home apps that installed on my phone,then I will choose one as default.My question is: Can I get the default home app's package name through codes?
Solve it,use the follow api.
public abstract int getPreferredActivities (List<IntentFilter> outFilters, List<ComponentName> outActivities, String packageName)
Did you have a look at: PackageManager.resolveActivity(),
Intent intent= new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo defaultLauncher= getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
String nameOfLauncherPkg= defaultLauncher.activityInfo.packageName;
Make sure you use HOME intent as you will have the launcher on home, obviously.
Haven't used but you can try it with another flag i.e.
PackageManager.GET_INTENT_FILTERS
in place of
PackageManager.MATCH_DEFAULT_ONLY
FINAL SOLUTION:
API packageManager,
public abstract int getPreferredActivities (List<IntentFilter> outFilters,List<ComponentName> outActivities, String packageName)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With