Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.os.Build; public class Main { public static boolean copyToClipboard(Context context, String text) { try { if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(text); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("text", text); clipboard.setPrimaryClip(clip); } return true; } catch (Exception e) { return false; } } }