FileDocCategorySizeDatePackage
LabeledIntent.javaAPI DocAndroid 5.1 API6489Thu Mar 12 22:22:10 GMT 2015android.content.pm

LabeledIntent

public class LabeledIntent extends android.content.Intent
A special subclass of Intent that can have a custom label/icon associated with it. Primarily for use with {@link Intent#ACTION_CHOOSER}.

Fields Summary
private String
mSourcePackage
private int
mLabelRes
private CharSequence
mNonLocalizedLabel
private int
mIcon
public static final Creator
CREATOR
Constructors Summary
public LabeledIntent(android.content.Intent origIntent, String sourcePackage, int labelRes, int icon)
Create a labeled intent from the given intent, supplying the label and icon resources for it.

param
origIntent The original Intent to copy.
param
sourcePackage The package in which the label and icon live.
param
labelRes Resource containing the label, or 0 if none.
param
icon Resource containing the icon, or 0 if none.

        super(origIntent);
        mSourcePackage = sourcePackage;
        mLabelRes = labelRes;
        mNonLocalizedLabel = null;
        mIcon = icon;
    
protected LabeledIntent(android.os.Parcel in)

hide

        readFromParcel(in);
    
public LabeledIntent(android.content.Intent origIntent, String sourcePackage, CharSequence nonLocalizedLabel, int icon)
Create a labeled intent from the given intent, supplying a textual label and icon resource for it.

param
origIntent The original Intent to copy.
param
sourcePackage The package in which the label and icon live.
param
nonLocalizedLabel Concrete text to use for the label.
param
icon Resource containing the icon, or 0 if none.

        super(origIntent);
        mSourcePackage = sourcePackage;
        mLabelRes = 0;
        mNonLocalizedLabel = nonLocalizedLabel;
        mIcon = icon;
    
public LabeledIntent(String sourcePackage, int labelRes, int icon)
Create a labeled intent with no intent data but supplying the label and icon resources for it.

param
sourcePackage The package in which the label and icon live.
param
labelRes Resource containing the label, or 0 if none.
param
icon Resource containing the icon, or 0 if none.

        mSourcePackage = sourcePackage;
        mLabelRes = labelRes;
        mNonLocalizedLabel = null;
        mIcon = icon;
    
public LabeledIntent(String sourcePackage, CharSequence nonLocalizedLabel, int icon)
Create a labeled intent with no intent data but supplying a textual label and icon resource for it.

param
sourcePackage The package in which the label and icon live.
param
nonLocalizedLabel Concrete text to use for the label.
param
icon Resource containing the icon, or 0 if none.

        mSourcePackage = sourcePackage;
        mLabelRes = 0;
        mNonLocalizedLabel = nonLocalizedLabel;
        mIcon = icon;
    
Methods Summary
public intgetIconResource()
Return any resource identifier that has been given for the label icon.

        return mIcon;
    
public intgetLabelResource()
Return any resource identifier that has been given for the label text.

        return mLabelRes;
    
public java.lang.CharSequencegetNonLocalizedLabel()
Return any concrete text that has been given for the label text.

        return mNonLocalizedLabel;
    
public java.lang.StringgetSourcePackage()
Return the name of the package holding label and icon resources.

        return mSourcePackage;
    
public android.graphics.drawable.DrawableloadIcon(PackageManager 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.

        if (mIcon != 0 && mSourcePackage != null) {
            Drawable icon = pm.getDrawable(mSourcePackage, mIcon, null);
            if (icon != null) {
                return icon;
            }
        }
        return null;
    
public java.lang.CharSequenceloadLabel(PackageManager pm)
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.

        if (mNonLocalizedLabel != null) {
            return mNonLocalizedLabel;
        }
        if (mLabelRes != 0 && mSourcePackage != null) {
            CharSequence label = pm.getText(mSourcePackage, mLabelRes, null);
            if (label != null) {
                return label;
            }
        }
        return null;
    
public voidreadFromParcel(android.os.Parcel in)

        super.readFromParcel(in);
        mSourcePackage = in.readString();
        mLabelRes = in.readInt();
        mNonLocalizedLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
        mIcon = in.readInt();
    
public voidwriteToParcel(android.os.Parcel dest, int parcelableFlags)

        super.writeToParcel(dest, parcelableFlags);
        dest.writeString(mSourcePackage);
        dest.writeInt(mLabelRes);
        TextUtils.writeToParcel(mNonLocalizedLabel, dest, parcelableFlags);
        dest.writeInt(mIcon);