如何以编程方式获取启动器和任务切换器的包名称?

How to programmatically get the package name for the launcher and task switcher?

有没有办法以编程方式获取主页启动器和任务切换器的包名称,即当我分别按下主页按钮和任务切换器按钮时启动的应用程序?

主屏幕包启动器

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