/** * Retrieve the current textual label associated with this resolution. This will call back on the * given PackageManager to load the label from the application. * * @param pm A PackageManager from which the label can be loaded; usually the PackageManager from * which you originally retrieved this item. * @return Returns a CharSequence containing the resolutions's label. If the item does not have a * label, its name is returned. */ public CharSequence loadLabel(PackageManager pm) { if (nonLocalizedLabel != null) { return nonLocalizedLabel; } CharSequence label; if (resolvePackageName != null && labelRes != 0) { label = pm.getText(resolvePackageName, labelRes, null); if (label != null) { return label.toString().trim(); } } ComponentInfo ci = getComponentInfo(); ApplicationInfo ai = ci.applicationInfo; if (labelRes != 0) { label = pm.getText(ci.packageName, labelRes, ai); if (label != null) { return label.toString().trim(); } } CharSequence data = ci.loadLabel(pm); // Make the data safe if (data != null) data = data.toString().trim(); return data; }
/** * Retrieve the textual description of the application. This will call back on the given * PackageManager to load the description from the application. * * @param pm A PackageManager from which the label can be loaded; usually the PackageManager from * which you originally retrieved this item. * @return Returns a CharSequence containing the application's description. If there is no * description, null is returned. */ public CharSequence loadDescription(PackageManager pm) { if (descriptionRes != 0) { CharSequence label = pm.getText(packageName, descriptionRes, this); if (label != null) { return label; } } return null; }
/** * Retrieve the label associated with this object. If the object does not have a label, null will * be returned, in which case you will probably want to load the label from the underlying * resolved info for the Intent. */ public CharSequence loadLabel(PackageManager pm) { if (mNonLocalizedLabel != null) { return mNonLocalizedLabel; } if (mLabelRes != 0 && mSourcePackage != null) { CharSequence label = pm.getText(mSourcePackage, mLabelRes, null); if (label != null) { return label; } } return null; }