# ChooserTarget

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/android/service/chooser/ChooserTarget#inhconstants)\|[Fields](https://developer.android.com/reference/android/service/chooser/ChooserTarget#lfields)\|[Ctors](https://developer.android.com/reference/android/service/chooser/ChooserTarget#pubctors)\|[Methods](https://developer.android.com/reference/android/service/chooser/ChooserTarget#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/service/chooser/ChooserTarget#inhmethods)  

# ChooserTarget

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/service/chooser/ChooserTarget "View this page in Kotlin")\|Java

`
public

final

class
ChooserTarget
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[Parcelable](https://developer.android.com/reference/android/os/Parcelable)`


`

|---|---------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.service.chooser.ChooserTarget |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 30.**   
For publishing direct share targets, please follow the instructions in https://developer.android.com/training/sharing/receive.html#providing-direct-share-targets instead.

A ChooserTarget represents a deep-link into an application as returned by a[ChooserTargetService](https://developer.android.com/reference/android/service/chooser/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.

<br />

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable) |-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) Descriptor bit used with[describeContents()](https://developer.android.com/reference/android/os/Parcelable#describeContents()): indicates that the Parcelable object's flattened representation includes a file descriptor.                                                                                                                                            | | `int` | [PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE) Flag for use with[writeToParcel(Parcel, int)](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)): the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

|                                                                                                                                                      ### Fields                                                                                                                                                      ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| ` public static final `[Creator](https://developer.android.com/reference/android/os/Parcelable.Creator)`<`[ChooserTarget](https://developer.android.com/reference/android/service/chooser/ChooserTarget)`>` | [CREATOR](https://developer.android.com/reference/android/service/chooser/ChooserTarget#CREATOR) <br /> |

|                                                                                                                                                                                                                                                                                                                                        ### Public constructors                                                                                                                                                                                                                                                                                                                                        ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ChooserTarget](https://developer.android.com/reference/android/service/chooser/ChooserTarget#ChooserTarget(java.lang.CharSequence,%20android.graphics.drawable.Icon,%20float,%20android.content.ComponentName,%20android.os.Bundle))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` title, `[Icon](https://developer.android.com/reference/android/graphics/drawable/Icon)` icon, float score, `[ComponentName](https://developer.android.com/reference/android/content/ComponentName)` componentName, `[Bundle](https://developer.android.com/reference/android/os/Bundle)` intentExtras) ` Construct a deep link target for presentation by a chooser UI. |

|                                                                                                                                                                         ### Public methods                                                                                                                                                                         ||
|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int`                                                                                    | ` `[describeContents](https://developer.android.com/reference/android/service/chooser/ChooserTarget#describeContents())`() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.                                    |
| ` `[ComponentName](https://developer.android.com/reference/android/content/ComponentName) | ` `[getComponentName](https://developer.android.com/reference/android/service/chooser/ChooserTarget#getComponentName())`() ` Returns the ComponentName of the Activity that should be launched for this ChooserTarget.                                                  |
| ` `[Icon](https://developer.android.com/reference/android/graphics/drawable/Icon)         | ` `[getIcon](https://developer.android.com/reference/android/service/chooser/ChooserTarget#getIcon())`() ` Returns the icon representing this target for display to a user.                                                                                             |
| ` `[Bundle](https://developer.android.com/reference/android/os/Bundle)                    | ` `[getIntentExtras](https://developer.android.com/reference/android/service/chooser/ChooserTarget#getIntentExtras())`() ` Returns the Bundle of extras to be added to an intent launched to this target.                                                               |
| ` float`                                                                                  | ` `[getScore](https://developer.android.com/reference/android/service/chooser/ChooserTarget#getScore())`() ` Returns the ranking score supplied by the creator of this ChooserTarget.                                                                                   |
| ` `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)         | ` `[getTitle](https://developer.android.com/reference/android/service/chooser/ChooserTarget#getTitle())`() ` Returns the title of this target for display to a user.                                                                                                    |
| ` `[String](https://developer.android.com/reference/java/lang/String)                     | ` `[toString](https://developer.android.com/reference/android/service/chooser/ChooserTarget#toString())`() ` Returns a string representation of the object.                                                                                                             |
| ` void`                                                                                   | ` `[writeToParcel](https://developer.android.com/reference/android/service/chooser/ChooserTarget#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/Parcel)` dest, int flags) ` Flatten this object in to a Parcel. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract int`  | ` `[describeContents](https://developer.android.com/reference/android/os/Parcelable#describeContents())`() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.                                    | | ` abstract void` | ` `[writeToParcel](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/Parcel)` dest, int flags) ` Flatten this object in to a Parcel. | ||

## Fields

### CREATOR

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final Creator<ChooserTarget> CREATOR
```

<br />

<br />

## Public constructors

### ChooserTarget

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public 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](https://developer.android.com/reference/android/service/chooser/ChooserTargetService#onGetChooserTargets(android.content.ComponentName,%20android.content.IntentFilter)). 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](https://developer.android.com/reference/android/os/Parcelable)types into the extras bundle, as the system will not be able to unparcel them to merge them.

<br />

<br />

|                                                         Parameters                                                          ||
|-----------------|------------------------------------------------------------------------------------------------------------|
| `title`         | `CharSequence`: title of this target that will be shown to a user <br />                                   |
| `icon`          | `Icon`: icon to represent this target <br />                                                               |
| `score`         | `float`: ranking score for this target between 0.0f and 1.0f, inclusive <br />                             |
| `componentName` | `ComponentName`: Name of the component to be launched if this target is chosen <br />                      |
| `intentExtras`  | `Bundle`: Bundle of extras to merge with the extras of the launched intent This value may be`null`. <br /> |

## Public methods

### describeContents

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public 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(android.os.Parcel, int)](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)), the return value of this method must include the[CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR)bit.

<br />

|                                                                                                                         Returns                                                                                                                         ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either`0`or[CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) <br /> |

### getComponentName

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public ComponentName getComponentName ()
```

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

<br />

|                                                                 Returns                                                                  ||
|----------------------------------------------------------------------------------------|--------------------------------------------------|
| [ComponentName](https://developer.android.com/reference/android/content/ComponentName) | the name of the target Activity to launch <br /> |

### getIcon

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

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

<br />

|                                                                         Returns                                                                          ||
|--------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [Icon](https://developer.android.com/reference/android/graphics/drawable/Icon) | the icon representing this target, intended to be shown to a user <br /> |

### getIntentExtras

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Bundle getIntentExtras ()
```

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

<br />

|                                                                   Returns                                                                    ||
|---------------------------------------------------------------------|-------------------------------------------------------------------------|
| [Bundle](https://developer.android.com/reference/android/os/Bundle) | the extras to merge with the extras of the intent being launched <br /> |

### getScore

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

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

<br />

|                                      Returns                                       ||
|---------|---------------------------------------------------------------------------|
| `float` | the ranking score for this target between 0.0f and 1.0f, inclusive <br /> |

### getTitle

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

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

<br />

|                                                                     Returns                                                                     ||
|--------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [CharSequence](https://developer.android.com/reference/java/lang/CharSequence) | the title of this target, intended to be shown to a user <br /> |

### toString

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String toString ()
```

Returns a string representation of the object.

<br />

|                                                      Returns                                                      ||
|--------------------------------------------------------------------|-----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representation of the object. <br /> |

### writeToParcel

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

|                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dest`  | `Parcel`: The Parcel in which the object should be written. This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                 |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or[Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE). Value is either`0`or a combination of[Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES <br /> |