Interface

ClipboardManager

Interface for managing the Clipboard.

Source set: Common
@Deprecated(
    "Use Clipboard instead, which supports suspend functions.",
    ReplaceWith("Clipboard", "androidx.compose.ui.platform.Clipboard"),
)
public interface ClipboardManager

Interface for managing the Clipboard.

Properties

nativeClipboard

Source set: Common
public val nativeClipboard: NativeClipboard

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

Throws: UnsupportedOperationException

If the current platform does not offer a native Clipboard interface.

Functions

getText

Source set: Common
public fun getText(): AnnotatedString?

This method get the text from the Clipboard.

Return

The text in the Clipboard. It could be null due to 2 reasons: 1. Clipboard is empty; 2. Cannot convert the CharSequence text in Clipboard to AnnotatedString.

hasText

Source set: Common
public fun hasText(): Boolean

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

getClip

Source set: Common
public fun getClip(): ClipEntry?

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.

setClip

Source set: Common
@Suppress("GetterSetterNames") public fun setClip(clipEntry: ClipEntry?): Unit

Puts the given clipEntry in platform's ClipboardManager.

Parameters

clipEntry Platform specific clip object that either holds data or links to it. Pass null to clear the clipboard.
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: