/** * Retrieve the current graphical icon associated with this resolution. This will call back on the * given PackageManager to load the icon from the application. * * @param pm A PackageManager from which the icon can be loaded; usually the PackageManager from * which you originally retrieved this item. * @return Returns a Drawable containing the resolution's icon. If the item does not have an icon, * the default activity icon is returned. */ public Drawable loadIcon(PackageManager pm) { Drawable dr; if (resolvePackageName != null && icon != 0) { dr = pm.getDrawable(resolvePackageName, icon, null); if (dr != null) { return dr; } } ComponentInfo ci = getComponentInfo(); ApplicationInfo ai = ci.applicationInfo; if (icon != 0) { dr = pm.getDrawable(ci.packageName, icon, ai); if (dr != null) { return dr; } } return ci.loadIcon(pm); }
/** * Retrieve the icon associated with this object. If the object does not have a icon, null will be * returned, in which case you will probably want to load the icon from the underlying resolved * info for the Intent. */ public Drawable loadIcon(PackageManager pm) { if (mIcon != 0 && mSourcePackage != null) { Drawable icon = pm.getDrawable(mSourcePackage, mIcon, null); if (icon != null) { return icon; } } return null; }