ClipboardManager
public
class
ClipboardManager
extends ClipboardManager
| java.lang.Object | ||
| ↳ | android.text.ClipboardManager | |
| ↳ | android.content.ClipboardManager | |
Interface to the clipboard service, for placing and retrieving text in the global clipboard.
You do not instantiate this class directly; instead, retrieve it through
getSystemService(Class.
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.
Developer Guides
For more information about using the clipboard framework, read the Copy and Paste developer guide.
See also:
Summary
Nested classes | |
|---|---|
interface |
ClipboardManager.OnPrimaryClipChangedListener
Defines a listener callback that is invoked when the primary clip on the clipboard changes. |
Public methods | |
|---|---|
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()
This method was deprecated
in API level 11.
Use |
boolean
|
hasPrimaryClip()
Returns true if there is currently a primary clip on the clipboard. |
boolean
|
hasText()
This method was deprecated
in API level 11.
Use |
void
|
removePrimaryClipChangedListener(ClipboardManager.OnPrimaryClipChangedListener what)
|
void
|
setPrimaryClip(ClipData clip)
Sets the current primary clip on the clipboard. |
void
|
setText(CharSequence text)
This method was deprecated
in API level 11.
Use |
Inherited methods | |
|---|---|
android.text.ClipboardManager
| |
java.lang.Object
| |
Public methods
addPrimaryClipChangedListener
void addPrimaryClipChangedListener (ClipboardManager.OnPrimaryClipChangedListener what)
| Parameters | |
|---|---|
what |
ClipboardManager.OnPrimaryClipChangedListener |
getPrimaryClip
ClipData getPrimaryClip ()
Returns the current primary clip on the clipboard.
| Returns | |
|---|---|
ClipData |
|
getPrimaryClipDescription
ClipDescription getPrimaryClipDescription ()
Returns a description of the current primary clip on the clipboard but not a copy of its data.
| Returns | |
|---|---|
ClipDescription |
|
getText
CharSequence getText ()
This method was deprecated
in API level 11.
Use getPrimaryClip() instead. This retrieves
the primary clip and tries to coerce it to a string.
Returns the text on the clipboard. It will eventually be possible to store types other than text too, in which case this will return null if the type cannot be coerced to text.
| Returns | |
|---|---|
CharSequence |
|
hasPrimaryClip
boolean hasPrimaryClip ()
Returns true if there is currently a primary clip on the clipboard.
| Returns | |
|---|---|
boolean |
|
hasText
boolean hasText ()
This method was deprecated
in API level 11.
Use hasPrimaryClip() instead.
Returns true if the clipboard contains text; false otherwise.
| Returns | |
|---|---|
boolean |
|
removePrimaryClipChangedListener
void removePrimaryClipChangedListener (ClipboardManager.OnPrimaryClipChangedListener what)
| Parameters | |
|---|---|
what |
ClipboardManager.OnPrimaryClipChangedListener |
setPrimaryClip
void setPrimaryClip (ClipData clip)
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.
|
setText
void setText (CharSequence text)
This method was deprecated
in API level 11.
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.
Sets the contents of the clipboard to the specified text.
| Parameters | |
|---|---|
text |
CharSequence |
Interfaces
- ClipboardManager.OnPrimaryClipChangedListener
- ComponentCallbacks
- ComponentCallbacks2
- ContentProvider.PipeDataWriter
- DialogInterface
- DialogInterface.OnCancelListener
- DialogInterface.OnClickListener
- DialogInterface.OnDismissListener
- DialogInterface.OnKeyListener
- DialogInterface.OnMultiChoiceClickListener
- DialogInterface.OnShowListener
- EntityIterator
- IntentSender.OnFinished
- Loader.OnLoadCanceledListener
- Loader.OnLoadCompleteListener
- ServiceConnection
- SharedPreferences
- SharedPreferences.Editor
- SharedPreferences.OnSharedPreferenceChangeListener
- SyncStatusObserver
Classes
- AbstractThreadedSyncAdapter
- AsyncQueryHandler
- AsyncQueryHandler.WorkerArgs
- AsyncQueryHandler.WorkerHandler
- AsyncTaskLoader
- BroadcastReceiver
- BroadcastReceiver.PendingResult
- ClipboardManager
- ClipData
- ClipData.Item
- ClipDescription
- ComponentName
- ContentProvider
- ContentProviderClient
- ContentProviderOperation
- ContentProviderOperation.Builder
- ContentProviderResult
- ContentQueryMap
- ContentResolver
- ContentUris
- ContentValues
- Context
- ContextWrapper
- CursorLoader
- Entity
- Entity.NamedContentValues
- Intent
- Intent.FilterComparison
- Intent.ShortcutIconResource
- IntentFilter
- IntentFilter.AuthorityEntry
- IntentSender
- Loader
- Loader.ForceLoadContentObserver
- MutableContextWrapper
- PeriodicSync
- QuickViewConstants
- RestrictionEntry
- RestrictionsManager
- SearchRecentSuggestionsProvider
- SyncAdapterType
- SyncContext
- SyncInfo
- SyncRequest
- SyncRequest.Builder
- SyncResult
- SyncStats
- UriMatcher
- UriPermission
Exceptions