获取Android应用程序的启动器活动名称 [英] Get the launcher Activity name of an android application
本文介绍了获取Android应用程序的启动器活动名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要获取启动器活动的名称才能从我的应用程序启动活动.任何解决方案
I need to get the name of launcher activity to launch the activity from my application. Any solution
推荐答案
使用以下代码获取所有包的启动器活动:
Use the following code to get the launcher activity of all packages:
final PackageManager pm = getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);
Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));
for (ResolveInfo temp : appList) {
Log.v("my logs", "package and activity name = "
+ temp.activityInfo.packageName + " "
+ temp.activityInfo.name);
}
这篇关于获取Android应用程序的启动器活动名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文