FileDocCategorySizeDatePackage
ComponentInfo.javaAPI DocAndroid 1.5 API4509Wed May 06 22:41:54 BST 2009android.content.pm

ComponentInfo

public class ComponentInfo extends PackageItemInfo
Base class containing information common to all application components ({@link ActivityInfo}, {@link ServiceInfo}). This class is not intended to be used by itself; it is simply here to share common definitions between all application components. 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 ApplicationInfo
applicationInfo
Global information about the application/package this component is a part of.
public String
processName
The name of the process this component should run in. From the "android:process" attribute or, if not set, the same as applicationInfo.processName.
public boolean
enabled
Indicates whether or not this component may be instantiated. Note that this value can be overriden by the one in its parent {@link ApplicationInfo}.
public boolean
exported
Set to true if this component is available for use by other applications. Comes from {@link android.R.attr#exported android:exported} of the <activity>, <receiver>, <service>, or <provider> tag.
Constructors Summary
public ComponentInfo()

    
      
    
public ComponentInfo(ComponentInfo orig)

        super(orig);
        applicationInfo = orig.applicationInfo;
        processName = orig.processName;
        enabled = orig.enabled;
        exported = orig.exported;
    
protected ComponentInfo(android.os.Parcel source)

        super(source);
        applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source);
        processName = source.readString();
        enabled = (source.readInt() != 0);
        exported = (source.readInt() != 0);
    
Methods Summary
protected voiddumpBack(android.util.Printer pw, java.lang.String prefix)

        if (applicationInfo != null) {
            pw.println(prefix + "ApplicationInfo:");
            applicationInfo.dump(pw, prefix + "  ");
        } else {
            pw.println(prefix + "ApplicationInfo: null");
        }
        super.dumpBack(pw, prefix);
    
protected voiddumpFront(android.util.Printer pw, java.lang.String prefix)

        super.dumpFront(pw, prefix);
        pw.println(prefix + "enabled=" + enabled + " exported=" + exported
                + " processName=" + processName);
    
public final intgetIconResource()
Return the icon resource identifier to use for this component. If the component defines an icon, that is used; else, the application icon is used.

return
The icon associated with this component.

        return icon != 0 ? icon : applicationInfo.icon;
    
public android.graphics.drawable.DrawableloadIcon(PackageManager pm)

        ApplicationInfo ai = applicationInfo;
        Drawable dr;
        if (icon != 0) {
            dr = pm.getDrawable(packageName, icon, ai);
            if (dr != null) {
                return dr;
            }
        }
        if (ai.icon != 0) {
            dr = pm.getDrawable(packageName, ai.icon, ai);
            if (dr != null) {
                return dr;
            }
        }
        return pm.getDefaultActivityIcon();
    
public java.lang.CharSequenceloadLabel(PackageManager pm)

        if (nonLocalizedLabel != null) {
            return nonLocalizedLabel;
        }
        ApplicationInfo ai = applicationInfo;
        CharSequence label;
        if (labelRes != 0) {
            label = pm.getText(packageName, labelRes, ai);
            if (label != null) {
                return label;
            }
        }
        if (ai.nonLocalizedLabel != null) {
            return ai.nonLocalizedLabel;
        }
        if (ai.labelRes != 0) {
            label = pm.getText(packageName, ai.labelRes, ai);
            if (label != null) {
                return label;
            }
        }
        return name;
    
public voidwriteToParcel(android.os.Parcel dest, int parcelableFlags)

        super.writeToParcel(dest, parcelableFlags);
        applicationInfo.writeToParcel(dest, parcelableFlags);
        dest.writeString(processName);
        dest.writeInt(enabled ? 1 : 0);
        dest.writeInt(exported ? 1 : 0);