Added in API level 11

ClipboardManager

open class ClipboardManager : ClipboardManager
kotlin.Any
   ↳ android.text.ClipboardManager
   ↳ android.content.ClipboardManager

Interface to the clipboard service, for placing and retrieving text in the global clipboard.

The ClipboardManager API itself is very simple: it consists of methods to atomically get and set the current primary clipboard data. That data is expressed as a ClipData object, which defines the protocol for data exchange between applications.

Summary

Nested classes
abstract

Defines a listener callback that is invoked when the primary clip on the clipboard changes.

Public methods
open Unit

open Unit

Clears any current primary clip on the clipboard.

open ClipData?

Returns the current primary clip on the clipboard.

open ClipDescription?

Returns a description of the current primary clip on the clipboard but not a copy of its data.

open CharSequence!

open Boolean

Returns true if there is currently a primary clip on the clipboard.

open Boolean

open Unit

open Unit

Sets the current primary clip on the clipboard.

open Unit

Public methods

addPrimaryClipChangedListener

Added in API level 11
open fun addPrimaryClipChangedListener(what: ClipboardManager.OnPrimaryClipChangedListener!): Unit

clearPrimaryClip

Added in API level 28
open fun clearPrimaryClip(): Unit

Clears any current primary clip on the clipboard.

getPrimaryClip

Added in API level 11
open fun getPrimaryClip(): ClipData?

Returns the current primary clip on the clipboard. If the application is not the default IME or does not have input focus this return null.

getPrimaryClipDescription

Added in API level 11
open fun getPrimaryClipDescription(): ClipDescription?

Returns a description of the current primary clip on the clipboard but not a copy of its data.

If the application is not the default IME or does not have input focus this return null.

getText

Added in API level 11
open fun getText(): CharSequence!

Deprecated: Use getPrimaryClip() instead. This retrieves the primary clip and tries to coerce it to a string.

hasPrimaryClip

Added in API level 11
open fun hasPrimaryClip(): Boolean

Returns true if there is currently a primary clip on the clipboard. If the application is not the default IME or the does not have input focus this will return false.

hasText

Added in API level 11
open fun hasText(): Boolean

Deprecated: Use hasPrimaryClip() instead.

removePrimaryClipChangedListener

Added in API level 11
open fun removePrimaryClipChangedListener(what: ClipboardManager.OnPrimaryClipChangedListener!): Unit

setPrimaryClip

Added in API level 11
open fun setPrimaryClip(clip: ClipData): Unit

Sets the current primary clip on the clipboard. This is the clip that is involved in normal cut and paste operations.

Parameters
clip ClipData: The clipped data item to set. This value cannot be null.

setText

Added in API level 11
open fun setText(text: CharSequence!): Unit

Deprecated: Use setPrimaryClip(android.content.ClipData) instead. This creates a ClippedItem holding the given text and sets it as the primary clip. It has no label or icon.