Methods Summary |
---|
public void | addPrimaryClipChangedListener(android.content.ClipboardManager$OnPrimaryClipChangedListener what)
synchronized (mPrimaryClipChangedListeners) {
if (mPrimaryClipChangedListeners.size() == 0) {
try {
getService().addPrimaryClipChangedListener(
mPrimaryClipChangedServiceListener, mContext.getOpPackageName());
} catch (RemoteException e) {
}
}
mPrimaryClipChangedListeners.add(what);
}
|
public ClipData | getPrimaryClip()Returns the current primary clip on the clipboard.
try {
return getService().getPrimaryClip(mContext.getOpPackageName());
} catch (RemoteException e) {
return null;
}
|
public ClipDescription | getPrimaryClipDescription()Returns a description of the current primary clip on the clipboard
but not a copy of its data.
try {
return getService().getPrimaryClipDescription(mContext.getOpPackageName());
} catch (RemoteException e) {
return null;
}
|
private static IClipboard | getService()
synchronized (sStaticLock) {
if (sService != null) {
return sService;
}
IBinder b = ServiceManager.getService("clipboard");
sService = IClipboard.Stub.asInterface(b);
return sService;
}
|
public java.lang.CharSequence | getText()
ClipData clip = getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
return clip.getItemAt(0).coerceToText(mContext);
}
return null;
|
public boolean | hasPrimaryClip()Returns true if there is currently a primary clip on the clipboard.
try {
return getService().hasPrimaryClip(mContext.getOpPackageName());
} catch (RemoteException e) {
return false;
}
|
public boolean | hasText()
try {
return getService().hasClipboardText(mContext.getOpPackageName());
} catch (RemoteException e) {
return false;
}
|
public void | removePrimaryClipChangedListener(android.content.ClipboardManager$OnPrimaryClipChangedListener what)
synchronized (mPrimaryClipChangedListeners) {
mPrimaryClipChangedListeners.remove(what);
if (mPrimaryClipChangedListeners.size() == 0) {
try {
getService().removePrimaryClipChangedListener(
mPrimaryClipChangedServiceListener);
} catch (RemoteException e) {
}
}
}
|
void | reportPrimaryClipChanged()
Object[] listeners;
synchronized (mPrimaryClipChangedListeners) {
final int N = mPrimaryClipChangedListeners.size();
if (N <= 0) {
return;
}
listeners = mPrimaryClipChangedListeners.toArray();
}
for (int i=0; i<listeners.length; i++) {
((OnPrimaryClipChangedListener)listeners[i]).onPrimaryClipChanged();
}
|
public 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.
try {
if (clip != null) {
clip.prepareToLeaveProcess();
}
getService().setPrimaryClip(clip, mContext.getOpPackageName());
} catch (RemoteException e) {
}
|
public void | setText(java.lang.CharSequence text)
setPrimaryClip(ClipData.newPlainText(null, text));
|