List of utility methods to do Clipboard Copy
void | onCopy(Context context, String content) on Copy ClipboardManager cmb = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText(content.trim()); |
void | copyToClipboard(Context context, String label, String string, int toastMessageId) copy To Clipboard ClipboardManager clipboard = (ClipboardManager) context
.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(label, string);
clipboard.setPrimaryClip(clip);
if (toastMessageId > 0) {
Toast.makeText(context, toastMessageId, Toast.LENGTH_LONG)
.show();
|
boolean | copyToClipboard(Context context, String lable, String text) copy To Clipboard try { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData .newPlainText(lable, text); clipboard.setPrimaryClip(clip); return true; } catch (Exception e) { ... |
boolean | copyToClipboard(Context context, String lable, String text) Set text as new main clip in the clipboard. Looper.prepare(); try { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData .newPlainText(lable, text); clipboard.setPrimaryClip(clip); return true; ... |
void | set(Context context, String value) set if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipboardManager clipboard = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("text", value); clipboard.setPrimaryClip(clipData); } else { ClipboardManager clipboard = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); ... |
boolean | setClipboard(Context context, String text) set Clipboard android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context
.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(text);
return true;
|
boolean | setText(final Context context, final CharSequence text) set Text if (context == null) return false; ((ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE)).setText(text); return true; |
boolean | setText(final Context context, final CharSequence text) set Text if (context == null) return false; ((ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE)) .setText(text != null ? text : ""); return true; |
void | copy(Context context, String content) copy ClipboardManager cmb = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText(content.trim()); |
void | copyText(Context context, String text) copy Text android.text.ClipboardManager cm = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); cm.setText(text); |