# ContentInfoCompat

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/ContentInfoCompat "View this page in Java")

<br />

```
class ContentInfoCompat
```

<br />

*** ** * ** ***

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

## Summary

|                                                                                                                   ### Nested types                                                                                                                    |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[ContentInfoCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat.Builder) Builder for[ContentInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat). |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FLAG_CONVERT_TO_PLAIN_TEXT](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat#FLAG_CONVERT_TO_PLAIN_TEXT())` = 1` Flag requesting that the content should be converted to plain text prior to inserting.                                                                                                |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SOURCE_APP](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat#SOURCE_APP())` = 0` Specifies that the operation was triggered by the app that contains the target view.                                                                                                                                  |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SOURCE_AUTOFILL](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat#SOURCE_AUTOFILL())` = 4` Specifies that the operation was triggered by the autofill framework.                                                                                                                                       |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SOURCE_CLIPBOARD](https://developer.android.com/reference/kotlin/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).                                                  |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SOURCE_DRAG_AND_DROP](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat#SOURCE_DRAG_AND_DROP())` = 3` Specifies that the operation was triggered by the drag/drop framework.                                                                                                                            |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SOURCE_INPUT_METHOD](https://developer.android.com/reference/kotlin/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).                                                                                       |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SOURCE_PROCESS_TEXT](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat#SOURCE_PROCESS_TEXT())` = 5` Specifies that the operation was triggered by a result from a[PROCESS_TEXT](https://developer.android.com/reference/android/content/Intent.html#ACTION_PROCESS_TEXT())action in the selection menu. |

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

```
const val FLAG_CONVERT_TO_PLAIN_TEXT = 1: Int
```

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)  

```
const val SOURCE_APP = 0: Int
```

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)  

```
const val SOURCE_AUTOFILL = 4: Int
```

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)  

```
const val SOURCE_CLIPBOARD = 1: Int
```

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)  

```
const val SOURCE_DRAG_AND_DROP = 3: Int
```

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)  

```
const val SOURCE_INPUT_METHOD = 2: Int
```

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)  

```
const val SOURCE_PROCESS_TEXT = 5: Int
```

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

## Public functions

### getClip

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

```
fun getClip(): ClipData
```

The data to be inserted.  

### getExtras

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

```
fun getExtras(): Bundle?
```

Optional additional metadata. If the source is[SOURCE_INPUT_METHOD](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat#SOURCE_INPUT_METHOD()), this will include the[opts](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)  

```
fun getFlags(): Int
```

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)  

```
fun getLinkUri(): Uri?
```

Optional http/https URI for the content that may be provided by the IME. This is only populated if the source is[SOURCE_INPUT_METHOD](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat#SOURCE_INPUT_METHOD())and if a non-empty[linkUri](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)  

```
fun getSource(): Int
```

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)  

```
fun partition(itemPredicate: Predicate<ClipData.Item!>): Pair<ContentInfoCompat!, ContentInfoCompat!>
```

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[ClipData](https://developer.android.com/reference/android/content/ClipData.html)items, the returned objects will contain all the same metadata as this[ContentInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat).  

|                                                                                                 Parameters                                                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `itemPredicate: `[Predicate](https://developer.android.com/reference/kotlin/androidx/core/util/Predicate)`<`[ClipData.Item](https://developer.android.com/reference/android/content/ClipData.Item.html)`!>` | The predicate to test each[ClipData.Item](https://developer.android.com/reference/android/content/ClipData.Item.html)to determine which partition to place it into. |

|                                                                                                                                              Returns                                                                                                                                               |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Pair](https://developer.android.com/reference/android/util/Pair.html)`<`[ContentInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat)`!, `[ContentInfoCompat](https://developer.android.com/reference/kotlin/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)
java-static fun partition(payload: ContentInfo, itemPredicate: Predicate<ClipData.Item!>): Pair<ContentInfo!, ContentInfo!>
```

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[ClipData](https://developer.android.com/reference/android/content/ClipData.html)items, the returned objects will contain all the same metadata as the passed-in[ContentInfo](https://developer.android.com/reference/android/view/ContentInfo.html).  

|                                                                                                Parameters                                                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `payload: `[ContentInfo](https://developer.android.com/reference/android/view/ContentInfo.html)                                                                                                           | payload to add to returned pair.                                                                                                                                    |
| `itemPredicate: `[Predicate](https://developer.android.com/reference/java/util/function/Predicate.html)`<`[ClipData.Item](https://developer.android.com/reference/android/content/ClipData.Item.html)`!>` | The predicate to test each[ClipData.Item](https://developer.android.com/reference/android/content/ClipData.Item.html)to determine which partition to place it into. |

|                                                                                                                          Returns                                                                                                                           |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Pair](https://developer.android.com/reference/android/util/Pair.html)`<`[ContentInfo](https://developer.android.com/reference/android/view/ContentInfo.html)`!, `[ContentInfo](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)
fun toContentInfo(): ContentInfo
```

Provides the[ContentInfo](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                                        |
|--------------------------------------------------------------------------------------|-----------------------|
| [ContentInfo](https://developer.android.com/reference/android/view/ContentInfo.html) | platform class object |

|                                                                         See also                                                                         |
|----------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [toContentInfoCompat](https://developer.android.com/reference/kotlin/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)
java-static fun toContentInfoCompat(platContentInfo: ContentInfo): ContentInfoCompat
```

Provides a backward-compatible wrapper for[ContentInfo](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                                                |
|---------------------------------------------------------------------------------------------------------|------------------------------------------|
| `platContentInfo: `[ContentInfo](https://developer.android.com/reference/android/view/ContentInfo.html) | platform class to wrap, must not be null |

|                                                 Returns                                                  |
|----------------------------------------------------------------------------------------------------------|---------------|
| [ContentInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/ContentInfoCompat) | wrapped class |

### toString

```
fun toString(): String
```