@SuppressWarnings("deprecation") @SuppressLint("NewApi") public static void copyToClipBoard(Context context, String strText) { final ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); manager.setText(strText); }
public static void set(Context context, String text) { if (!VipApplication.getInstance().lockLooper) { Looper.prepare(); VipApplication.getInstance().lockLooper = true; } ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText(text); Log.v("DEV", "Clipboard set:" + text); }
public static void copy2Clipboard(String str2Copy, Context context) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { android.content.ClipboardManager clipboardManager = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clipboardManager.setText(str2Copy); } else { android.text.ClipboardManager clipboardManager = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clipboardManager.setText(str2Copy); } }
@SuppressLint("NewApi") @SuppressWarnings("deprecation") public void copyToClipboard(String str) { if (android.os.Build.VERSION.SDK_INT < 11) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(str); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(str); } Toast toast = Toast.makeText(this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT); toast.show(); }
@SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override public void onCopyClick() { try { ClipboardManager manager = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE); logger.d("menu#onCopyClick content:%s", mMsgInfo.getContent()); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { ClipData data = ClipData.newPlainText("data", mMsgInfo.getContent()); manager.setPrimaryClip(data); } else { manager.setText(mMsgInfo.getContent()); } } catch (Exception e) { logger.e(e.getMessage()); } }
public static void copy(String content, Context context) { ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText(content); }
private void copy(CharSequence text) { ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); cm.setText(text); }