use of android.content.ClipboardManager in project weiciyuan by qii.
the class BrowserCommentFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch(item.getItemId()) {
case R.id.menu_comment:
intent = new Intent(getActivity(), WriteReplyToCommentActivity.class);
intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
intent.putExtra("msg", msg);
getActivity().startActivity(intent);
break;
case R.id.menu_share:
buildShareActionMenu();
return true;
case R.id.menu_copy:
ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(ClipData.newPlainText("sinaweibo", content.getText().toString()));
Toast.makeText(getActivity(), getString(R.string.copy_successfully), Toast.LENGTH_SHORT).show();
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}
use of android.content.ClipboardManager in project weiciyuan by qii.
the class MainTimeLineActivity method readClipboard.
//read clipboard to know whether there are any string link can be opened
private void readClipboard() {
ClipboardManager cm = (ClipboardManager) getApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData cmContent = cm.getPrimaryClip();
if (cmContent == null) {
return;
}
ClipData.Item item = cmContent.getItemAt(0);
if (item != null) {
String url = item.coerceToText(this).toString();
boolean a = !TextUtils.isEmpty(url) && !url.equals(SettingUtility.getLastFoundWeiboAccountLink());
boolean b = Utility.isWeiboAccountIdLink(url) || Utility.isWeiboAccountDomainLink(url);
if (a && b) {
OpenWeiboAccountLinkDialog dialog = OpenWeiboAccountLinkDialog.newInstance(url);
dialog.show(getSupportFragmentManager(), "");
SettingUtility.setLastFoundWeiboAccountLink(url);
}
}
}
use of android.content.ClipboardManager in project zxingfragmentlib by mitoyarzun.
the class ClipboardInterface method hasText.
public static boolean hasText(Context context) {
ClipboardManager clipboard = getManager(context);
ClipData clip = clipboard.getPrimaryClip();
return clip != null && clip.getItemCount() > 0;
}
use of android.content.ClipboardManager in project LollipopShowcase by mikepenz.
the class DetailActivity method fillRow.
/**
* fill the rows with some information
*
* @param view
* @param title
* @param description
*/
public void fillRow(View view, final String title, final String description) {
TextView titleView = (TextView) view.findViewById(R.id.title);
titleView.setText(title);
TextView descriptionView = (TextView) view.findViewById(R.id.description);
descriptionView.setText(description);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("AppInfo", description);
clipboard.setPrimaryClip(clip);
Snackbar.make(mCoordinatorLayout, "Copied " + title, Snackbar.LENGTH_SHORT).show();
}
});
}
use of android.content.ClipboardManager in project qksms by moezbhatti.
the class CopyUnreadMessageTextService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
Uri threadUri = intent.getParcelableExtra(EXTRA_THREAD_URI);
String messages = SmsHelper.getUnreadMessageText(this, threadUri);
((ClipboardManager) getSystemService(CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText(messages, messages));
mHandler.post(new RunnableToast(this, R.string.toast_copy_text, Toast.LENGTH_SHORT));
}
Aggregations