Android examples for Android OS:Clipboard
set Clipboard
//package com.java2s; import android.annotation.SuppressLint; import android.content.Context; public class Main { @SuppressLint("NewApi") public static void setClipboard(Context context, String text) { if (getSystemVersion(context) >= android.os.Build.VERSION_CODES.HONEYCOMB) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(text);/*from w ww. j a va2 s . com*/ } else { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(text); } } public static int getSystemVersion(Context context) { int currentapiVersion = android.os.Build.VERSION.SDK_INT; return currentapiVersion; } }