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));
}