FileDocCategorySizeDatePackage
PackageItemInfo.javaAPI DocAndroid 1.5 API6658Wed May 06 22:41:54 BST 2009android.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 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.
Constructors Summary
public PackageItemInfo()

    
public PackageItemInfo(PackageItemInfo orig)

        name = orig.name;
        packageName = orig.packageName;
        labelRes = orig.labelRes;
        nonLocalizedLabel = orig.nonLocalizedLabel;
        icon = orig.icon;
        metaData = orig.metaData;
    
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();
        metaData = source.readBundle();
    
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)

        pw.println(prefix + "name=" + name);
        pw.println(prefix + "packageName=" + packageName);
        pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
                + " nonLocalizedLabel=" + nonLocalizedLabel
                + " icon=0x" + Integer.toHexString(icon));
    
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 default activity icon is returned.

        if (icon != 0) {
            Drawable dr = pm.getDrawable(packageName, icon, null);
            if (dr != null) {
                return dr;
            }
        }
        return pm.getDefaultActivityIcon();
    
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, null);
            if (label != null) {
                return label;
            }
        }
        if(name != null) {
            return name;
        }
        return packageName;
    
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, null);
            }
        }
        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.writeBundle(metaData);