Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/content/ClipData.Item#nestedclasses) \| [Ctors](https://developer.android.com/reference/android/content/ClipData.Item#pubctors) \| [Methods](https://developer.android.com/reference/android/content/ClipData.Item#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/content/ClipData.Item#inhmethods)

# ClipData.Item

*** ** * ** ***

` public static class ClipData.Item `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.ClipData.Item |

<br />

*** ** * ** ***

Description of a single item in a ClipData.

The types than an individual item can currently contain are:

- Text: a basic string of text. This is actually a CharSequence, so it can be formatted text supported by corresponding Android built-in style spans. (Custom application spans are not supported and will be stripped when transporting through the clipboard.)
- Intent: an arbitrary Intent object. A typical use is the shortcut to create when pasting a clipped item on to the home screen.
- Uri: a URI reference. This may be any URI (such as an http: URI representing a bookmark), however it is often a content: URI. Using content provider references as clips like this allows an application to share complex or large clips through the standard content provider facilities.

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/content/ClipData.Item.Builder` A builder for a ClipData Item. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/content/ClipData.Item#Item(android.content.Intent)(https://developer.android.com/reference/android/content/Intent intent) ` Create an Item consisting of an arbitrary Intent. |
| ` https://developer.android.com/reference/android/content/ClipData.Item#Item(android.net.Uri)(https://developer.android.com/reference/android/net/Uri uri) ` Create an Item consisting of an arbitrary URI. |
| ` https://developer.android.com/reference/android/content/ClipData.Item#Item(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence text) ` Create an Item consisting of a single block of (possibly styled) text. |
| ` https://developer.android.com/reference/android/content/ClipData.Item#Item(java.lang.CharSequence,%20android.content.Intent,%20android.net.Uri)(https://developer.android.com/reference/java/lang/CharSequence text, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/net/Uri uri) ` Create a complex Item, containing multiple representations of text, Intent, and/or URI. |
| ` https://developer.android.com/reference/android/content/ClipData.Item#Item(java.lang.CharSequence,%20java.lang.String)(https://developer.android.com/reference/java/lang/CharSequence text, https://developer.android.com/reference/java/lang/String htmlText) ` Create an Item consisting of a single block of (possibly styled) text, with an alternative HTML formatted representation. |
| ` https://developer.android.com/reference/android/content/ClipData.Item#Item(java.lang.CharSequence,%20java.lang.String,%20android.content.Intent,%20android.net.Uri)(https://developer.android.com/reference/java/lang/CharSequence text, https://developer.android.com/reference/java/lang/String htmlText, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/net/Uri uri) ` Create a complex Item, containing multiple representations of text, HTML text, Intent, and/or URI. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/content/ClipData.Item#coerceToHtmlText(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Turn this item into HTML text, regardless of the type of data it actually contains. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/content/ClipData.Item#coerceToStyledText(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Like `https://developer.android.com/reference/android/content/ClipData.Item#coerceToHtmlText(android.content.Context)`, but any text that would be returned as HTML formatting will be returned as text with style spans. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/content/ClipData.Item#coerceToText(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Turn this item into text, regardless of the type of data it actually contains. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/content/ClipData.Item#getHtmlText()() ` Retrieve the raw HTML text contained in this Item. |
| ` https://developer.android.com/reference/android/content/Intent` | ` https://developer.android.com/reference/android/content/ClipData.Item#getIntent()() ` Retrieve the raw Intent contained in this Item. |
| ` https://developer.android.com/reference/android/content/IntentSender` | ` https://developer.android.com/reference/android/content/ClipData.Item#getIntentSender()() ` Returns the `https://developer.android.com/reference/android/content/IntentSender` in this Item. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/content/ClipData.Item#getText()() ` Retrieve the raw text contained in this Item. |
| ` https://developer.android.com/reference/android/view/textclassifier/TextLinks` | ` https://developer.android.com/reference/android/content/ClipData.Item#getTextLinks()() ` Returns the results of text classification run on the raw text contained in this item, if it was performed, and if any entities were found in the text. |
| ` https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/content/ClipData.Item#getUri()() ` Retrieve the raw URI contained in this Item. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/content/ClipData.Item#toString()() ` Returns a string representation of the object. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` 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 https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` 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` ` 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` ` 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*.

## Public constructors

### Item

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

```
public Item (Intent intent)
```

Create an Item consisting of an arbitrary Intent.

<br />

| Parameters ||
|---|---|
| `intent` | `Intent` <br /> |

### Item

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

```
public Item (Uri uri)
```

Create an Item consisting of an arbitrary URI.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri` <br /> |

### Item

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

```
public Item (CharSequence text)
```

Create an Item consisting of a single block of (possibly styled) text.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence` <br /> |

### Item

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

```
public Item (CharSequence text, 
                Intent intent, 
                Uri uri)
```

Create a complex Item, containing multiple representations of text, Intent, and/or URI.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence` <br /> |
| `intent` | `Intent` <br /> |
| `uri` | `Uri` <br /> |

### Item

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

```
public Item (CharSequence text, 
                String htmlText)
```

Create an Item consisting of a single block of (possibly styled) text, with an alternative HTML formatted representation. You *must* supply a plain text representation in addition to HTML text; coercion will not be done from HTML formatted text into plain text.

**Warning:** Use content: URI for sharing large clip data. ClipData.Item doesn't accept an HTML text if it's larger than 800KB.

<br />

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence` <br /> |
| `htmlText` | `String` <br /> |

### Item

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

```
public Item (CharSequence text, 
                String htmlText, 
                Intent intent, 
                Uri uri)
```

Create a complex Item, containing multiple representations of text, HTML text, Intent, and/or URI. If providing HTML text, you *must* supply a plain text representation as well; coercion will not be done from HTML formatted text into plain text.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence` <br /> |
| `htmlText` | `String` <br /> |
| `intent` | `Intent` <br /> |
| `uri` | `Uri` <br /> |

## Public methods

### coerceToHtmlText

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

```
public String coerceToHtmlText (Context context)
```

Turn this item into HTML text, regardless of the type of data it actually contains.

The algorithm for deciding what text to return is:

- If `https://developer.android.com/reference/android/content/ClipData.Item#getHtmlText()` is non-null, return that.
- If `https://developer.android.com/reference/android/content/ClipData.Item#getText()` is non-null, return that, converting to valid HTML text. If this text contains style spans, `https://developer.android.com/reference/android/text/Html#toHtml(android.text.Spanned)` is used to convert them to HTML formatting.
- If `https://developer.android.com/reference/android/content/ClipData.Item#getUri()` is non-null, try to retrieve its data as a text stream from its content provider. If the provider can supply text/html data, that will be preferred and returned as-is. Otherwise, any text/\* data will be returned and escaped to HTML. If it is not a content: URI or the content provider does not supply a text representation, HTML text containing a link to the URI will be returned.
- If `https://developer.android.com/reference/android/content/ClipData.Item#getIntent()` is non-null, convert that to an intent: URI and return as an HTML link.
- Otherwise, return an empty string.

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The caller's Context, from which its ContentResolver and other things can be retrieved. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | Returns the item's representation as HTML text. <br /> |

### coerceToStyledText

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

```
public CharSequence coerceToStyledText (Context context)
```

Like `https://developer.android.com/reference/android/content/ClipData.Item#coerceToHtmlText(android.content.Context)`, but any text that would be returned as HTML formatting will be returned as text with style spans.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The caller's Context, from which its ContentResolver and other things can be retrieved. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | Returns the item's textual representation. <br /> |

### coerceToText

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

```
public CharSequence coerceToText (Context context)
```

Turn this item into text, regardless of the type of data it actually contains.

The algorithm for deciding what text to return is:

- If `https://developer.android.com/reference/android/content/ClipData.Item#getText()` is non-null, return that.
- If `https://developer.android.com/reference/android/content/ClipData.Item#getUri()` is non-null, try to retrieve its data as a text stream from its content provider. If this succeeds, copy the text into a String and return it. If it is not a content: URI or the content provider does not supply a text representation, return the raw URI as a string.
- If `https://developer.android.com/reference/android/content/ClipData.Item#getIntent()` is non-null, convert that to an intent: URI and return it.
- Otherwise, return an empty string.

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The caller's Context, from which its ContentResolver and other things can be retrieved. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | Returns the item's textual representation. <br /> |

### getHtmlText

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

```
public String getHtmlText ()
```

Retrieve the raw HTML text contained in this Item.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getIntent

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

```
public Intent getIntent ()
```

Retrieve the raw Intent contained in this Item.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/Intent` | <br /> |

### getIntentSender

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

```
public IntentSender getIntentSender ()
```

Returns the `https://developer.android.com/reference/android/content/IntentSender` in this Item.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/IntentSender` | This value may be `null`. <br /> |

### getText

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

```
public CharSequence getText ()
```

Retrieve the raw text contained in this Item.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | <br /> |

### getTextLinks

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

```
public TextLinks getTextLinks ()
```

Returns the results of text classification run on the raw text contained in this item, if it was performed, and if any entities were found in the text. Classification is generally only performed on the first item in clip data, and only if the text is below a certain length.

Returns `null` if classification was not performed, or if no entities were found in the text.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextLinks` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/ClipDescription#getConfidenceScore(java.lang.String)`

### getUri

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

```
public Uri getUri ()
```

Retrieve the raw URI contained in this Item.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

### toString

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

```
public String toString ()
```

Returns a string representation of the object.

<br />

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