# ClipboardManager

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/platform/ClipboardManager.kt+class:androidx.compose.ui.platform.ClipboardManager) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface ClipboardManager
  ```

*** ** * ** ***

> [!CAUTION]
> **This interface is deprecated.**   
> Use Clipboard instead, which supports suspend functions, use this instead:
>
> ```kotlin
> Clipboard
> ```

Interface for managing the Clipboard.

## Summary

| ### Public functions |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipEntry?` | `[getClip](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#getClip())()` **This function is deprecated.** Use Clipboard instead, which supports suspend functions. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString?` | `[getText](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#getText())()` **This function is deprecated.** Use Clipboard instead, which supports suspend functions. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[hasText](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#hasText())()` **This function is deprecated.** Use Clipboard instead, which supports suspend functions. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setClip](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#setClip(androidx.compose.ui.platform.ClipEntry))(clipEntry: https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipEntry?)` **This function is deprecated.** Use Clipboard instead, which supports suspend functions. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setText](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#setText(androidx.compose.ui.text.AnnotatedString))(annotatedString: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString)` **This function is deprecated.** Use Clipboard instead, which supports suspend functions. | Cmn |

| ### Public properties |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/NativeClipboard` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#nativeClipboard()` **This property is deprecated.** Use Clipboard instead, which supports suspend functions. | Cmn |

## Public functions

### getClip

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
open fun [getClip](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#getClip())(): ClipEntry?
```

> [!CAUTION]
> **This function is deprecated.**   
> Use Clipboard instead, which supports suspend functions, use this instead:
>
> ```kotlin
> Clipboard
> ```

Returns the clipboard entry that's provided by the platform's ClipboardManager.

This item can include arbitrary content like images, videos, or any data that may be provided through a mediator. Returned entry may contain multiple items with different types.

It's safe to call this function without triggering Clipboard access warnings on mobile platforms.

### getText

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
fun [getText](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#getText())(): AnnotatedString?
```

> [!CAUTION]
> **This function is deprecated.**   
> Use Clipboard instead, which supports suspend functions, use this instead:
>
> ```kotlin
> Clipboard
> ```

This method get the text from the Clipboard.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString?` | The text in the Clipboard. It could be null due to 2 reasons: 1. Clipboard is empty; 2. Cannot convert the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` text in Clipboard to `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString`. |

### hasText

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.4.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
open fun [hasText](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#hasText())(): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Use Clipboard instead, which supports suspend functions, use this instead:
>
> ```kotlin
> Clipboard
> ```

This method returns true if there is a text in the Clipboard, false otherwise.

### setClip

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
open fun [setClip](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#setClip(androidx.compose.ui.platform.ClipEntry))(clipEntry: ClipEntry?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use Clipboard instead, which supports suspend functions, use this instead:
>
> ```kotlin
> Clipboard
> ```

Puts the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#setClip(androidx.compose.ui.platform.ClipEntry)` in platform's ClipboardManager.

| Parameters |
|---|---|
| `clipEntry: https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipEntry?` | Platform specific clip object that either holds data or links to it. Pass null to clear the clipboard. |

### setText

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
fun [setText](https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ClipboardManager#setText(androidx.compose.ui.text.AnnotatedString))(annotatedString: AnnotatedString): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use Clipboard instead, which supports suspend functions, use this instead:
>
> ```kotlin
> Clipboard
> ```

This method put the text into the Clipboard.

| Parameters |
|---|---|
| `annotatedString: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` to be put into Clipboard. |

## Public properties

### nativeClipboard

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
open val nativeClipboard: NativeClipboard
```

> [!CAUTION]
> **This property is deprecated.**   
> Use Clipboard instead, which supports suspend functions, use this instead:
>
> ```kotlin
> Clipboard
> ```

Returns the native clipboard that exposes the full functionality of platform clipboard.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | If the current platform does not offer a native Clipboard interface. |