public final class ChooserTarget extends Object implements Parcelable
ChooserTargetService
.
A chooser target represents a specific deep link target into an application exposed for selection by the user. This might be a frequently emailed contact, a recently active group messaging conversation, a folder in a cloud storage app, a collection of related items published on a social media service or any other contextually relevant grouping of target app + relevant metadata.
Creators of chooser targets should consult the relevant design guidelines for the type of target they are presenting. For example, targets involving people should be presented with a circular icon.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<ChooserTarget> |
CREATOR |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
ChooserTarget(CharSequence title,
Icon icon,
float score,
ComponentName componentName,
Bundle intentExtras)
Construct a deep link target for presentation by a chooser UI.
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
ComponentName |
getComponentName()
Returns the ComponentName of the Activity that should be launched for this ChooserTarget.
|
Icon |
getIcon()
Returns the icon representing this target for display to a user.
|
Bundle |
getIntentExtras()
Returns the Bundle of extras to be added to an intent launched to this target.
|
float |
getScore()
Returns the ranking score supplied by the creator of this ChooserTarget.
|
CharSequence |
getTitle()
Returns the title of this target for display to a user.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final Parcelable.Creator<ChooserTarget> CREATOR
public ChooserTarget(CharSequence title, Icon icon, float score, ComponentName componentName, Bundle intentExtras)
A target is composed of a title and an icon for presentation to the user. The UI presenting this target may truncate the title if it is too long to be presented in the available space, as well as crop, resize or overlay the supplied icon.
The creator of a target may supply a ranking score. This score is assumed to be relative
to the other targets supplied by the same
query
.
Scores should be in the range from 0.0f (unlikely match) to 1.0f (very relevant match).
Scores for a set of targets do not need to sum to 1.
The ComponentName must be the name of an Activity component in the creator's own package, or an exported component from any other package. You may provide an optional Bundle of extras that will be merged into the final intent before it is sent to the target Activity; use this to add any additional data about the deep link that the target activity will read. e.g. conversation IDs, email addresses, etc.
Take care not to place custom Parcelable
types into
the extras bundle, as the system will not be able to unparcel them to merge them.
title
- title of this target that will be shown to a usericon
- icon to represent this targetscore
- ranking score for this target between 0.0f and 1.0f, inclusivecomponentName
- Name of the component to be launched if this target is chosenintentExtras
- Bundle of extras to merge with the extras of the launched intentpublic CharSequence getTitle()
public Icon getIcon()
public float getScore()
public ComponentName getComponentName()
public Bundle getIntentExtras()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.