FileDocCategorySizeDatePackage
PackageItemInfo.javaAPI DocAndroid 5.1 API12673Thu Mar 12 22:22:10 GMT 2015android.content.pm

PackageItemInfo

public class PackageItemInfo extends Object
Base class containing information common to all package items held by the package manager. This provides a very common basic set of attributes: a label, icon, and meta-data. This class is not intended to be used by itself; it is simply here to share common definitions between all items returned by the package manager. As such, it does not itself implement Parcelable, but does provide convenience methods to assist in the implementation of Parcelable in subclasses.

Fields Summary
public String
name
Public name of this item. From the "android:name" attribute.
public String
packageName
Name of the package that this item is in.
public int
labelRes
A string resource identifier (in the package's resources) of this component's label. From the "label" attribute or, if not set, 0.
public CharSequence
nonLocalizedLabel
The string provided in the AndroidManifest file, if any. You probably don't want to use this. You probably want {@link PackageManager#getApplicationLabel}
public int
icon
A drawable resource identifier (in the package's resources) of this component's icon. From the "icon" attribute or, if not set, 0.
public int
banner
A drawable resource identifier (in the package's resources) of this component's banner. From the "banner" attribute or, if not set, 0.
public int
logo
A drawable resource identifier (in the package's resources) of this component's logo. Logos may be larger/wider than icons and are displayed by certain UI elements in place of a name or name/icon combination. From the "logo" attribute or, if not set, 0.
public android.os.Bundle
metaData
Additional meta-data associated with this component. This field will only be filled in if you set the {@link PackageManager#GET_META_DATA} flag when requesting the info.
public int
showUserIcon
If different of UserHandle.USER_NULL, The icon of this item will be the one of that user.
Constructors Summary
public PackageItemInfo()

        showUserIcon = UserHandle.USER_NULL;
    
protected PackageItemInfo(android.os.Parcel source)

        name = source.readString();
        packageName = source.readString();
        labelRes = source.readInt();
        nonLocalizedLabel
                = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        icon = source.readInt();
        logo = source.readInt();
        metaData = source.readBundle();
        banner = source.readInt();
        showUserIcon = source.readInt();
    
public PackageItemInfo(PackageItemInfo orig)

        name = orig.name;
        if (name != null) name = name.trim();
        packageName = orig.packageName;
        labelRes = orig.labelRes;
        nonLocalizedLabel = orig.nonLocalizedLabel;
        if (nonLocalizedLabel != null) nonLocalizedLabel = nonLocalizedLabel.toString().trim();
        icon = orig.icon;
        banner = orig.banner;
        logo = orig.logo;
        metaData = orig.metaData;
        showUserIcon = orig.showUserIcon;
    
Methods Summary
protected voiddumpBack(android.util.Printer pw, java.lang.String prefix)

        // no back here
    
protected voiddumpFront(android.util.Printer pw, java.lang.String prefix)

        if (name != null) {
            pw.println(prefix + "name=" + name);
        }
        pw.println(prefix + "packageName=" + packageName);
        if (labelRes != 0 || nonLocalizedLabel != null || icon != 0 || banner != 0) {
            pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
                    + " nonLocalizedLabel=" + nonLocalizedLabel
                    + " icon=0x" + Integer.toHexString(icon)
                    + " banner=0x" + Integer.toHexString(banner));
        }
    
protected ApplicationInfogetApplicationInfo()
Get the ApplicationInfo for the application to which this item belongs, if available, otherwise returns null.

return
Returns the ApplicationInfo of this item, or null if not known.
hide

        return null;
    
public android.graphics.drawable.DrawableloadBanner(PackageManager pm)
Retrieve the current graphical banner associated with this item. This will call back on the given PackageManager to load the banner from the application.

param
pm A PackageManager from which the banner can be loaded; usually the PackageManager from which you originally retrieved this item.
return
Returns a Drawable containing the item's banner. If the item does not have a banner, this method will return null.

        if (banner != 0) {
            Drawable dr = pm.getDrawable(packageName, banner, getApplicationInfo());
            if (dr != null) {
                return dr;
            }
        }
        return loadDefaultBanner(pm);
    
protected android.graphics.drawable.DrawableloadDefaultBanner(PackageManager pm)
Retrieve the default graphical banner associated with this item.

param
pm A PackageManager from which the banner can be loaded; usually the PackageManager from which you originally retrieved this item.
return
Returns a Drawable containing the item's default banner or null if no default logo is available.
hide

        return null;
    
public android.graphics.drawable.DrawableloadDefaultIcon(PackageManager pm)
Retrieve the default graphical icon associated with this item.

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 item's default icon such as the default activity icon.
hide

        return pm.getDefaultActivityIcon();
    
protected android.graphics.drawable.DrawableloadDefaultLogo(PackageManager pm)
Retrieve the default graphical logo associated with this item.

param
pm A PackageManager from which the logo can be loaded; usually the PackageManager from which you originally retrieved this item.
return
Returns a Drawable containing the item's default logo or null if no default logo is available.
hide

        return null;
    
public android.graphics.drawable.DrawableloadIcon(PackageManager pm)
Retrieve the current graphical icon associated with this item. 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 item's icon. If the item does not have an icon, the item's default icon is returned such as the default activity icon.

        return pm.loadItemIcon(this, getApplicationInfo());
    
public java.lang.CharSequenceloadLabel(PackageManager pm)
Retrieve the current textual label associated with this item. 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 item's label. If the item does not have a label, its name is returned.

        if (nonLocalizedLabel != null) {
            return nonLocalizedLabel;
        }
        if (labelRes != 0) {
            CharSequence label = pm.getText(packageName, labelRes, getApplicationInfo());
            if (label != null) {
                return label.toString().trim();
            }
        }
        if (name != null) {
            return name;
        }
        return packageName;
    
public android.graphics.drawable.DrawableloadLogo(PackageManager pm)
Retrieve the current graphical logo associated with this item. This will call back on the given PackageManager to load the logo from the application.

param
pm A PackageManager from which the logo can be loaded; usually the PackageManager from which you originally retrieved this item.
return
Returns a Drawable containing the item's logo. If the item does not have a logo, this method will return null.

        if (logo != 0) {
            Drawable d = pm.getDrawable(packageName, logo, getApplicationInfo());
            if (d != null) {
                return d;
            }
        }
        return loadDefaultLogo(pm);
    
public android.graphics.drawable.DrawableloadUnbadgedIcon(PackageManager pm)
Retrieve the current graphical icon associated with this item without the addition of a work badge if applicable. 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 item's icon. If the item does not have an icon, the item's default icon is returned such as the default activity icon.

        return pm.loadUnbadgedItemIcon(this, getApplicationInfo());
    
public android.content.res.XmlResourceParserloadXmlMetaData(PackageManager pm, java.lang.String name)
Load an XML resource attached to the meta-data of this item. This will retrieved the name meta-data entry, and if defined call back on the given PackageManager to load its XML file from the application.

param
pm A PackageManager from which the XML can be loaded; usually the PackageManager from which you originally retrieved this item.
param
name Name of the meta-date you would like to load.
return
Returns an XmlPullParser you can use to parse the XML file assigned as the given meta-data. If the meta-data name is not defined or the XML resource could not be found, null is returned.

        if (metaData != null) {
            int resid = metaData.getInt(name);
            if (resid != 0) {
                return pm.getXml(packageName, resid, getApplicationInfo());
            }
        }
        return null;
    
public voidwriteToParcel(android.os.Parcel dest, int parcelableFlags)

        dest.writeString(name);
        dest.writeString(packageName);
        dest.writeInt(labelRes);
        TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
        dest.writeInt(icon);
        dest.writeInt(logo);
        dest.writeBundle(metaData);
        dest.writeInt(banner);
        dest.writeInt(showUserIcon);