copy To Clipboard for HONEYCOMB - Android android.content

Android examples for android.content:Clipboard

Description

copy To Clipboard for HONEYCOMB

Demo Code

import android.content.ClipData;
import android.content.Context;
import android.os.Build;

public class Main{

    public static void copyToClipboard(Context context, String text) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            clipboard.setText(text);//from   w w w.j a  v  a  2s  . c  om
        } else {
            android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Copy", text);
            clipboard.setPrimaryClip(clip);
        }
    }

}

Related Tutorials