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! |
getText() |
| open Boolean |
Returns true if there is currently a primary clip on the clipboard. |
| open Boolean |
hasText() |
| open Unit | |
| open Unit |
setPrimaryClip(clip: ClipData)Sets the current primary clip on the clipboard. |
| open Unit |
setText(text: CharSequence!) |
Public methods
addPrimaryClipChangedListener
open fun addPrimaryClipChangedListener(what: ClipboardManager.OnPrimaryClipChangedListener!): Unit
clearPrimaryClip
open fun clearPrimaryClip(): Unit
Clears any current primary clip on the clipboard.
getPrimaryClip
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
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
open fungetText(): CharSequence!
Deprecated: Use getPrimaryClip() instead. This retrieves the primary clip and tries to coerce it to a string.
hasPrimaryClip
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.
removePrimaryClipChangedListener
open fun removePrimaryClipChangedListener(what: ClipboardManager.OnPrimaryClipChangedListener!): Unit
setPrimaryClip
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. |
See Also
setText
open funsetText(text: CharSequence!): Unit
Deprecated: Use setPrimaryClip(ClipData) instead. This creates a ClippedItem holding the given text and sets it as the primary clip. It has no label or icon.