本文介绍了获取Android应用程序的启动活动名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要发射活动的名称,从我的应用程序启动活动。 任何解决方案
I need to get the name of launcher activity to launch the activity from my application. Any solution
推荐答案使用下面的code让所有包的发射活动:
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应用程序的启动活动名称
发布评论