List of usage examples for android.content ClipData newHtmlText
static public ClipData newHtmlText(CharSequence label, CharSequence text, String htmlText)
From source file:de.enlightened.peris.SocialFragment.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") private void storePostInClipboard() { //Copy text support for all Android versions if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { final ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); final ClipData cd = ClipData.newHtmlText(this.selectedPost.author + "'s Social Post", this.selectedPost.body, this.selectedPost.body); clipboard.setPrimaryClip(cd);/*from ww w . j av a 2 s.c om*/ } else { final android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(this.selectedPost.body); } final Toast toast = Toast.makeText(this.getActivity(), "Text copied!", Toast.LENGTH_SHORT); toast.show(); }
From source file:tv.acfun.video.CommentsActivity.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override//from w ww.j av a2s . c om public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Object o = parent.getItemAtPosition(position); if (o == null || !(o instanceof Comment)) return false; Comment c = (Comment) o; ClipboardManager ma = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { ClipData text = ClipData.newHtmlText(c.userName, c.content, c.content); ((android.content.ClipboardManager) ma).setPrimaryClip(text); } else { ma.setText(c.content); } Toast.makeText(this, "#" + c.count + "?", 0).show(); return true; }
From source file:de.enlightened.peris.PostsFragment.java
@SuppressLint("NewApi") private void storePostInClipboard() { //Copy text support for all Android versions if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { final ClipboardManager clipboard = (ClipboardManager) this.activity .getSystemService(Context.CLIPBOARD_SERVICE); final ClipData cd = ClipData.newHtmlText(this.currentThreadSubject, this.selectedPost.body, this.selectedPost.body); clipboard.setPrimaryClip(cd);//w w w .j a v a 2s. c o m } else { final android.text.ClipboardManager clipboard = (android.text.ClipboardManager) this.activity .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(this.selectedPost.body); } final Toast toast = Toast.makeText(this.activity, "Text copied!", Toast.LENGTH_SHORT); toast.show(); }
From source file:tv.acfun.a63.CommentsActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override//from ww w . j ava 2s. c o m public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Object o = parent.getItemAtPosition(position); if (o == null || !(o instanceof Comment)) return false; Comment c = (Comment) o; ClipboardManager ma = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { ClipData text = ClipData.newHtmlText(c.userName, c.content, c.content); ((android.content.ClipboardManager) ma).setPrimaryClip(text); } else { ma.setText(c.content); } Toast.makeText(this, "#" + c.count + "?", 0).show(); return true; }