Android examples for Android OS:Clipboard
copy To Clipboard And Later
//package com.java2s; import android.annotation.TargetApi; import android.content.Context; import android.os.Build; import android.support.annotation.NonNull; public class Main { @TargetApi(Build.VERSION_CODES.HONEYCOMB) private static void copyToClipboard11AndLater(@NonNull Context context, @NonNull String toCopy) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData .newPlainText("Copied Text", toCopy); clipboard.setPrimaryClip(clip);/*from w w w. j ava 2 s . c o m*/ } }