How can I get the package name of the current laun

2019-01-17 00:27发布

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

1条回答
趁早两清
2楼-- · 2019-01-17 00:49

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;
查看更多
登录 后发表回答