Android APIs
public final class

ChooserTarget

extends Object
implements Parcelable
java.lang.Object
   ↳ android.service.chooser.ChooserTarget

Class Overview

A ChooserTarget represents a deep-link into an application as returned by a 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.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<ChooserTarget> CREATOR
Public Constructors
ChooserTarget(CharSequence title, Icon icon, float score, ComponentName componentName, Bundle intentExtras)
Construct a deep link target for presentation by a chooser UI.
Public Methods
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled 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 containing a concise, human-readable description of this object.
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<ChooserTarget> CREATOR

Added in API level 23

Public Constructors

public ChooserTarget (CharSequence title, Icon icon, float score, ComponentName componentName, Bundle intentExtras)

Added in API level 23

Construct a deep link target for presentation by a chooser UI.

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.

Parameters
title title of this target that will be shown to a user
icon icon to represent this target
score ranking score for this target between 0.0f and 1.0f, inclusive
componentName Name of the component to be launched if this target is chosen
intentExtras Bundle of extras to merge with the extras of the launched intent

Public Methods

public int describeContents ()

Added in API level 23

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public ComponentName getComponentName ()

Added in API level 23

Returns the ComponentName of the Activity that should be launched for this ChooserTarget.

Returns
  • the name of the target Activity to launch

public Icon getIcon ()

Added in API level 23

Returns the icon representing this target for display to a user. The UI displaying the icon may crop, resize or overlay this icon.

Returns
  • the icon representing this target, intended to be shown to a user

public Bundle getIntentExtras ()

Added in API level 23

Returns the Bundle of extras to be added to an intent launched to this target.

Returns
  • the extras to merge with the extras of the intent being launched

public float getScore ()

Added in API level 23

Returns the ranking score supplied by the creator of this ChooserTarget. Values are between 0.0f and 1.0f. The UI displaying the target may take this score into account when sorting and merging targets from multiple sources.

Returns
  • the ranking score for this target between 0.0f and 1.0f, inclusive

public CharSequence getTitle ()

Added in API level 23

Returns the title of this target for display to a user. The UI displaying the title may truncate this title if it is too long to be displayed in full.

Returns
  • the title of this target, intended to be shown to a user

public String toString ()

Added in API level 23

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel dest, int flags)

Added in API level 23

Flatten this object in to a Parcel.

Parameters
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_WRITE_RETURN_VALUE.