LabeledIntentpublic 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.
super(origIntent);
mSourcePackage = sourcePackage;
mLabelRes = labelRes;
mNonLocalizedLabel = null;
mIcon = icon;
| protected LabeledIntent(android.os.Parcel in)
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.
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.
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.
mSourcePackage = sourcePackage;
mLabelRes = 0;
mNonLocalizedLabel = nonLocalizedLabel;
mIcon = icon;
|
Methods Summary |
---|
public int | getIconResource()Return any resource identifier that has been given for the label icon.
return mIcon;
| public int | getLabelResource()Return any resource identifier that has been given for the label text.
return mLabelRes;
| public java.lang.CharSequence | getNonLocalizedLabel()Return any concrete text that has been given for the label text.
return mNonLocalizedLabel;
| public java.lang.String | getSourcePackage()Return the name of the package holding label and icon resources.
return mSourcePackage;
| public android.graphics.drawable.Drawable | loadIcon(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.CharSequence | loadLabel(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 void | readFromParcel(android.os.Parcel in)
super.readFromParcel(in);
mSourcePackage = in.readString();
mLabelRes = in.readInt();
mNonLocalizedLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
mIcon = in.readInt();
| public void | writeToParcel(android.os.Parcel dest, int parcelableFlags)
super.writeToParcel(dest, parcelableFlags);
dest.writeString(mSourcePackage);
dest.writeInt(mLabelRes);
TextUtils.writeToParcel(mNonLocalizedLabel, dest, parcelableFlags);
dest.writeInt(mIcon);
|
|