Reputation: 1356
Both classes ResolveInfo
and ApplicationInfo
(which extends PackageItemInfo
) have a loadLabel
method to "current textual label associated with this item". I tried running the following code, the first block to print out the label associated with the Play Music app obtained through an intent query, and the second to print out the label associated with the app obtained through a query using the package name. The first one prints "Play Music" but the second prints out "Google Play Music". What's going on here?
PackageManager pm = getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> activities = pm.queryIntentActivities(intent,
PackageManager.GET_META_DATA);
for (ResolveInfo activity : activities) {
// prints out "Play Music"
Log.d("butt", "" + activity.loadLabel(pm));
}
ApplicationInfo appInfo = null;
try {
appInfo = pm.getApplicationInfo("com.google.android.music", 0);
} catch (NameNotFoundException e) { }
if (appInfo != null) {
// prints out "Google Play Music"
Log.d("butt", "" + appInfo.loadLabel(pm));
}
Upvotes: 0
Views: 761
Reputation: 326
ApplicationInfo documentation:
Information you can retrieve about a particular application. This corresponds to information collected from the AndroidManifest.xml's tag.
Information that is returned from resolving an intent against an IntentFilter. This partially corresponds to information collected from the AndroidManifest.xml's tags.
From the above, it seems like Google Play Music is the name of the application and Play Music is the name of an activity in the application that responds to intents.
Upvotes: 1