Most visited

Recently visited

Added in API level 23

ChooserTarget

public final class ChooserTarget
extends Object implements Parcelable

java.lang.Object
   ↳ android.service.chooser.ChooserTarget


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

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

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Fields

CREATOR

Added in API level 23
Creator<ChooserTarget> CREATOR

Public constructors

ChooserTarget

Added in API level 23
ChooserTarget (CharSequence title, 
                Icon icon, 
                float score, 
                ComponentName componentName, 
                Bundle intentExtras)

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 CharSequence: title of this target that will be shown to a user
icon Icon: icon to represent this target
score float: ranking score for this target between 0.0f and 1.0f, inclusive
componentName ComponentName: Name of the component to be launched if this target is chosen
intentExtras Bundle: Bundle of extras to merge with the extras of the launched intent

Public methods

describeContents

Added in API level 23
int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getComponentName

Added in API level 23
ComponentName getComponentName ()

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

Returns
ComponentName the name of the target Activity to launch

getIcon

Added in API level 23
Icon getIcon ()

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

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

getIntentExtras

Added in API level 23
Bundle getIntentExtras ()

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

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

getScore

Added in API level 23
float getScore ()

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
float the ranking score for this target between 0.0f and 1.0f, inclusive

getTitle

Added in API level 23
CharSequence getTitle ()

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
CharSequence the title of this target, intended to be shown to a user

toString

Added in API level 23
String toString ()

Returns a string representation of the object. In general, the 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())
 

Returns
String a string representation of the object.

writeToParcel

Added in API level 23
void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

Hooray!