Android:从Intent获取App-Name

问题描述:

我目前正在研究多图像选择器控件。我正在使用这个允许用户为图像选择相机或图库用于生成用户选择的可能意图列表的解决方案。

I'm currently working on a multi image picker control. I'm using this Allow user to select camera or gallery for image solution for generating a list of possible intents from which the user picks one.

如下所示:

List<ResolveInfo> listGall = packageManager.queryIntentActivities(gallIntent, 0);
for (ResolveInfo res : listGall) {
    final Intent finalIntent = new Intent(gallIntent);
    finalIntent.setComponent(new ComponentName(res.activityInfo.packageName,     res.activityInfo.name));
yourIntentsList.add(finalIntent);
}

但我可以通过ResolveInfo及其属性解析的所有名称都不是用户友好的标签。所以我正在寻找获取给定活动的启动器名称的方法。

But all names I can resolve by ResolveInfo and its properties are not user friendly labels. So I'm looking for way to get the launcher name for the given activities.

使用 loadLabel () ResolveInfo 上获取用户友好标签。 这是一个示例应用,用于演示此内容。

Use loadLabel() on the ResolveInfo to get a "user friendly label". Here is a sample app that demonstrates this.