# ContentInfoCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/ContentInfoCompat.java+class:androidx.core.view.ContentInfoCompat) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

*** ** * ** ***


```
public final class ContentInfoCompat
```

<br />

*** ** * ** ***

Holds all the relevant data for a request to `https://developer.android.com/reference/androidx/core/view/OnReceiveContentListener`. This is a backward-compatible wrapper for the platform class `https://developer.android.com/reference/android/view/ContentInfo.html`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/core/view/ContentInfoCompat.Builder` Builder for `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat`. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#FLAG_CONVERT_TO_PLAIN_TEXT() = 1` Flag requesting that the content should be converted to plain text prior to inserting. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_APP() = 0` Specifies that the operation was triggered by the app that contains the target view. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_AUTOFILL() = 4` Specifies that the operation was triggered by the autofill framework. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_CLIPBOARD() = 1` Specifies that the operation was triggered by a paste from the clipboard (e.g. "Paste" or "Paste as plain text" action in the insertion/selection menu). |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_DRAG_AND_DROP() = 3` Specifies that the operation was triggered by the drag/drop framework. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_INPUT_METHOD() = 2` Specifies that the operation was triggered from the soft keyboard (also known as input method editor or IME). |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_PROCESS_TEXT() = 5` Specifies that the operation was triggered by a result from a `https://developer.android.com/reference/android/content/Intent.html#ACTION_PROCESS_TEXT` action in the selection menu. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ClipData.html` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#getClip()()` The data to be inserted. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#getExtras()()` Optional additional metadata. |
| `int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#getFlags()()` Optional flags that control the insertion behavior. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#getLinkUri()()` Optional http/https URI for the content that may be provided by the IME. |
| `int` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#getSource()()` The source of the operation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/androidx/core/view/ContentInfoCompat, https://developer.android.com/reference/androidx/core/view/ContentInfoCompat>` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#partition(androidx.core.util.Predicate<android.content.ClipData.Item>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/util/Predicate<https://developer.android.com/reference/android/content/ClipData.Item.html> itemPredicate)` Partitions this content based on the given predicate. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/android/view/ContentInfo.html, https://developer.android.com/reference/android/view/ContentInfo.html>` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 31) https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#partition(android.view.ContentInfo,java.util.function.Predicate<android.content.ClipData.Item>)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ContentInfo.html payload, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/function/Predicate.html<https://developer.android.com/reference/android/content/ClipData.Item.html> itemPredicate )` Partitions content based on the given predicate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ContentInfo.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 31) https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#toContentInfo()()` Provides the `https://developer.android.com/reference/android/view/ContentInfo.html` represented by this object. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/ContentInfoCompat` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 31) https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#toContentInfoCompat(android.view.ContentInfo)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ContentInfo.html platContentInfo)` Provides a backward-compatible wrapper for `https://developer.android.com/reference/android/view/ContentInfo.html`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#toString()()` |

## Constants

### FLAG_CONVERT_TO_PLAIN_TEXT

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final int FLAG_CONVERT_TO_PLAIN_TEXT = 1
```

Flag requesting that the content should be converted to plain text prior to inserting.

### SOURCE_APP

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final int SOURCE_APP = 0
```

Specifies that the operation was triggered by the app that contains the target view.

### SOURCE_AUTOFILL

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

```
public static final int SOURCE_AUTOFILL = 4
```

Specifies that the operation was triggered by the autofill framework. See https://developer.android.com/guide/topics/text/autofill for more info.

### SOURCE_CLIPBOARD

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final int SOURCE_CLIPBOARD = 1
```

Specifies that the operation was triggered by a paste from the clipboard (e.g. "Paste" or "Paste as plain text" action in the insertion/selection menu).

### SOURCE_DRAG_AND_DROP

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final int SOURCE_DRAG_AND_DROP = 3
```

Specifies that the operation was triggered by the drag/drop framework. See https://developer.android.com/guide/topics/ui/drag-drop for more info.

### SOURCE_INPUT_METHOD

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final int SOURCE_INPUT_METHOD = 2
```

Specifies that the operation was triggered from the soft keyboard (also known as input method editor or IME). See https://developer.android.com/guide/topics/text/image-keyboard for more info.

### SOURCE_PROCESS_TEXT

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

```
public static final int SOURCE_PROCESS_TEXT = 5
```

Specifies that the operation was triggered by a result from a `https://developer.android.com/reference/android/content/Intent.html#ACTION_PROCESS_TEXT` action in the selection menu.

## Public methods

### getClip

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @NonNull ClipData getClip()
```

The data to be inserted.

### getExtras

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable Bundle getExtras()
```

Optional additional metadata. If the source is `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_INPUT_METHOD()`, this will include the `https://developer.android.com/reference/android/view/inputmethod/InputConnection.html#commitContent(android.view.inputmethod.InputContentInfo, int, android.os.Bundle)` passed by the IME.

### getFlags

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public int getFlags()
```

Optional flags that control the insertion behavior. See `FLAG_` constants.

### getLinkUri

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable Uri getLinkUri()
```

Optional http/https URI for the content that may be provided by the IME. This is only populated if the source is `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#SOURCE_INPUT_METHOD()` and if a non-empty `https://developer.android.com/reference/android/view/inputmethod/InputContentInfo.html#getLinkUri()` was passed by the IME.

### getSource

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public int getSource()
```

The source of the operation. See `SOURCE_` constants. Future versions of Android may pass additional values.

### partition

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @NonNull Pair<ContentInfoCompat, ContentInfoCompat> partition(@NonNull Predicate<ClipData.Item> itemPredicate)
```

Partitions this content based on the given predicate.

This function classifies the content and organizes it into a pair, grouping the items that matched vs didn't match the predicate.

Except for the `https://developer.android.com/reference/android/content/ClipData.html` items, the returned objects will contain all the same metadata as this `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/util/Predicate<https://developer.android.com/reference/android/content/ClipData.Item.html> itemPredicate` | The predicate to test each `https://developer.android.com/reference/android/content/ClipData.Item.html` to determine which partition to place it into. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/androidx/core/view/ContentInfoCompat, https://developer.android.com/reference/androidx/core/view/ContentInfoCompat>` | A pair containing the partitioned content. The pair's first object will have the content that matched the predicate, or null if none of the items matched. The pair's second object will have the content that didn't match the predicate, or null if all of the items matched. |

### partition

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

```
@RequiresApi(value = 31)
public static @NonNull Pair<ContentInfo, ContentInfo> partition(
    @NonNull ContentInfo payload,
    @NonNull Predicate<ClipData.Item> itemPredicate
)
```

Partitions content based on the given predicate.

This function classifies the content and organizes it into a pair, grouping the items that matched vs didn't match the predicate.

Except for the `https://developer.android.com/reference/android/content/ClipData.html` items, the returned objects will contain all the same metadata as the passed-in `https://developer.android.com/reference/android/view/ContentInfo.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ContentInfo.html payload` | payload to add to returned pair. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/function/Predicate.html<https://developer.android.com/reference/android/content/ClipData.Item.html> itemPredicate` | The predicate to test each `https://developer.android.com/reference/android/content/ClipData.Item.html` to determine which partition to place it into. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/android/view/ContentInfo.html, https://developer.android.com/reference/android/view/ContentInfo.html>` | A pair containing the partitioned content. The pair's first object will have the content that matched the predicate, or null if none of the items matched. The pair's second object will have the content that didn't match the predicate, or null if all of the items matched. |

### toContentInfo

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

```
@RequiresApi(value = 31)
public @NonNull ContentInfo toContentInfo()
```

Provides the `https://developer.android.com/reference/android/view/ContentInfo.html` represented by this object.

This method is not supported on devices running SDK \<= 30 since the platform class will not be available.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ContentInfo.html` | platform class object |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/ContentInfoCompat#toContentInfoCompat(android.view.ContentInfo)` |   |

### toContentInfoCompat

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

```
@RequiresApi(value = 31)
public static @NonNull ContentInfoCompat toContentInfoCompat(@NonNull ContentInfo platContentInfo)
```

Provides a backward-compatible wrapper for `https://developer.android.com/reference/android/view/ContentInfo.html`.

This method is not supported on devices running SDK \<= 30 since the platform class will not be available.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ContentInfo.html platContentInfo` | platform class to wrap, must not be null |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/ContentInfoCompat` | wrapped class |

### toString

```
public @NonNull String toString()
```