List of usage examples for android.content Context CLIPBOARD_SERVICE
String CLIPBOARD_SERVICE
To view the source code for android.content Context CLIPBOARD_SERVICE.
Click Source Link
From source file:Main.java
@NonNull public static String paste(Context context) { ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = manager.getPrimaryClip(); ClipData.Item item = clipData.getItemAt(0); return item.getText().toString(); }
From source file:Main.java
public static void copyText(Context context, String text) { ClipboardManager cmbName = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipDataName = ClipData.newPlainText(null, text); cmbName.setPrimaryClip(clipDataName); }
From source file:Main.java
public static void copy2Clipboard(Context context, String content) { content = content.trim();//w w w . ja v a 2 s. c o m ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText(content.trim()); }
From source file:Main.java
public static void putString(Context context, String string) { ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); manager.setPrimaryClip(ClipData.newPlainText("text", string)); }
From source file:Main.java
public static void copy(Context context, String label, String content) { ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); cmb.setPrimaryClip(ClipData.newPlainText(label, content)); }
From source file:Main.java
public static void copy(Context context, String str) { ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); String lable = str;//ww w. j a v a 2 s .co m if (str.length() > 10) lable = str.substring(0, 10); clipboardManager.setPrimaryClip(ClipData.newPlainText(lable, str)); }
From source file:Main.java
@SuppressWarnings("deprecation") public static void copyToClipboard(Context context, String content) { ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (cm != null) { cm.setText(content);/*from w w w . j a v a 2s .c o m*/ } }
From source file:Main.java
public static void copyToClipboard(final Context context, final String text) { final ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); cbm.setPrimaryClip(ClipData.newPlainText(context.getPackageName(), text)); }
From source file:Main.java
/** * Copy text to clip board/* w w w . j a va 2s . co m*/ * @param context * @param text */ public static void setClipboardText(Context context, String text) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(text); }
From source file:Main.java
public static void copyToClipBoard(Context context, String key, String value) { ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText(key, value); clipboardManager.setPrimaryClip(clipData); }