please use the Android.text.ClipboardManager before SDK11
Java code
- import Android.text.ClipboardManager;
- ......
- Clipboardmanager Clipboardmanager = (clipboardmanager) getsystemservice (Context.clipboard_service);
- Clipboardmanager.settext ("content");
- if (Clipboardmanager.hastext ()) {
- Clipboardmanager.gettext ();
- }
Android.text.ClipboardManager was discarded from SDK11, using its subclass android.content.ClipboardManager substitution, also discarded and settext/gettext/ HasText method, using Setprimaryclip/getprimaryclip/hasprimaryclip instead
Java code
- import Android.content.ClipboardManager;
- ......
- Clipboardmanager Clipboardmanager = (clipboardmanager) getsystemservice (Context.clipboard_service);
- Clipboardmanager.setprimaryclip (Clipdata.newplaintext (null, "content"));
- if (Clipboardmanager.hasprimaryclip ()) {
- Clipboardmanager.getprimaryclip (). Getitemat (0). GetText ();
- }
- public class Clipboardutils {
@SuppressWarnings ("deprecation")
public static void CopyToClipboard (context context, String text) {
Android.text.ClipboardManager cbm = (Android.text.ClipboardManager) context.getsystemservice (context.clipboard_ SERVICE);
Cbm.settext (text);
}
@SuppressWarnings ("deprecation")
public static Charsequence Getclipboardtext (context context) {
Android.text.ClipboardManager cbm = (Android.text.ClipboardManager) context.getsystemservice (context.clipboard_ SERVICE);
return Cbm.gettext ();
}
}
How Android Clipboard operations are used under different versions of the API