List of usage examples for android.content ClipboardManager setText
@Deprecated public void setText(CharSequence text)
From source file:Main.java
public static void clip(Context context, String text) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboardManager = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboardManager.setText(text); } else {/*from w w w . j a va 2 s . c om*/ ClipboardManager clipboardManager = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboardManager.setPrimaryClip(ClipData.newPlainText("content", text)); } }
From source file:Main.java
/** * Copy tags to clipboard as multi-line text in the form * key1=value1//from w w w. j a v a 2s.c om * key2=value2 * ..... * @param tags */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") public static void copyTags(Context ctx, Map<String, String> tags) { StringBuffer tagsAsText = new StringBuffer(); for (String key : tags.keySet()) { tagsAsText.append(key + "=" + tags.get(key) + "\n"); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipboardManager clipboard = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("OSM Tags", tagsAsText.toString()); clipboard.setPrimaryClip(clip); } else { android.text.ClipboardManager oldClipboard = (android.text.ClipboardManager) ctx .getSystemService(Context.CLIPBOARD_SERVICE); oldClipboard.setText(tagsAsText.toString()); } }
From source file:Main.java
/** * This is only called when oldAPi is passed as true on {@link #addItemToClipboard(Context, String, String, boolean)} * @param context The context, required to get the Cliboard System Service. * @param value The value to store on the clipboard. *//*from w w w . j av a2s . c om*/ @SuppressWarnings("deprecation") private static void addTextToClipboard(final Context context, final String value) { android.text.ClipboardManager manager = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); manager.setText(value); }
From source file:Main.java
@SuppressLint("NewApi") public static void copyToClipboard(Context context, String message) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipData clip = ClipData.newPlainText("", message); clipboard.setPrimaryClip(clip);//from w ww .jav a2s .c om } else { clipboard.setText(message); } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void copyText(Context context, String text) { ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipData clip = ClipData.newPlainText("", text); cm.setPrimaryClip(clip);//w ww . j ava2 s .c om } else { //noinspection deprecation cm.setText(text); } }
From source file:Main.java
@SuppressWarnings("deprecation") public static void setText(Context context, CharSequence sequence) { ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipData clip = ClipData.newPlainText("ClipboardManagerUtil", sequence); clipboardManager.setPrimaryClip(clip); } else {/*from ww w . j av a 2s. co m*/ clipboardManager.setText(sequence); } }
From source file:Main.java
public static void copyToClipboard(Context context, String label, String content) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(label, content); clipboard.setPrimaryClip(clip);//from ww w. j a v a 2s . c o m } else { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText("text to clip"); } }
From source file:Main.java
@SuppressLint("NewApi") public static void copyToClipboard(Context context, String label, String text) { if (isHoneycombOrHigher()) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText(label, text); clipboard.setPrimaryClip(clip);//w w w. j av a 2 s. c o m } else { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(text); } }
From source file:com.javielinux.utils.TweetActions.java
public static void copyToClipboard(FragmentActivity activity, InfoTweet infoTweet) { try {//from w w w . ja va2 s . c o m ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(infoTweet.getText()); Utils.showMessage(activity, activity.getString(R.string.copied_to_clipboard)); } catch (NoClassDefFoundError e) { Utils.showMessage(activity, activity.getString(R.string.error_general)); e.printStackTrace(); } }
From source file:org.fourthline.android.feeds.FeedEntryDetailsActivity.java
protected void copyFeedEntryLink() { if (currentFeedEntryLink != null) { log.fine("Copying feed entry URL to clipboard: " + currentFeedEntryLink); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(currentFeedEntryLink); Toast.makeText(this, R.string.article_url_copied_to_clipboard, Toast.LENGTH_SHORT).show(); }/*from w w w . j av a 2 s . c o m*/ }