public class ClipboardManager extends ClipboardManager
You do not instantiate this class directly; instead, retrieve it through
Context.getSystemService(java.lang.String)
.
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.
For more information about using the clipboard framework, read the Copy and Paste developer guide.
Modifier and Type | Class and Description |
---|---|
static interface |
ClipboardManager.OnPrimaryClipChangedListener
Defines a listener callback that is invoked when the primary clip on the clipboard changes.
|
Constructor and Description |
---|
ClipboardManager(Context context,
Handler handler) |
Modifier and Type | Method and Description |
---|---|
void |
addPrimaryClipChangedListener(ClipboardManager.OnPrimaryClipChangedListener what) |
ClipData |
getPrimaryClip()
Returns the current primary clip on the clipboard.
|
ClipDescription |
getPrimaryClipDescription()
Returns a description of the current primary clip on the clipboard
but not a copy of its data.
|
CharSequence |
getText()
Deprecated.
Use
getPrimaryClip() instead. This retrieves
the primary clip and tries to coerce it to a string. |
boolean |
hasPrimaryClip()
Returns true if there is currently a primary clip on the clipboard.
|
boolean |
hasText()
Deprecated.
Use
hasPrimaryClip() instead. |
void |
removePrimaryClipChangedListener(ClipboardManager.OnPrimaryClipChangedListener what) |
void |
setPrimaryClip(ClipData clip)
Sets the current primary clip on the clipboard.
|
void |
setText(CharSequence text)
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. |
public void setPrimaryClip(ClipData clip)
clip
- The clipped data item to set.public ClipData getPrimaryClip()
public ClipDescription getPrimaryClipDescription()
public boolean hasPrimaryClip()
public void addPrimaryClipChangedListener(ClipboardManager.OnPrimaryClipChangedListener what)
public void removePrimaryClipChangedListener(ClipboardManager.OnPrimaryClipChangedListener what)
public CharSequence getText()
getPrimaryClip()
instead. This retrieves
the primary clip and tries to coerce it to a string.ClipboardManager
getText
in class ClipboardManager
public void setText(CharSequence text)
setPrimaryClip(ClipData)
instead. This
creates a ClippedItem holding the given text and sets it as the
primary clip. It has no label or icon.ClipboardManager
setText
in class ClipboardManager
public boolean hasText()
hasPrimaryClip()
instead.ClipboardManager
hasText
in class ClipboardManager