copy Into Clipboard - Android Android OS

Android examples for Android OS:Clipboard

Description

copy Into Clipboard

Demo Code


//package com.java2s;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;

public class Main {
    public static void copyIntoClipboard(String value, Context context) {
        copyIntoClipboard("clipboardItem", value, context);
    }//from ww  w  .  j  ava  2  s .c o m

    public static void copyIntoClipboard(String label, String content,
            Context context) {
        ClipboardManager clipboard = (ClipboardManager) context
                .getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText(label, content);
        clipboard.setPrimaryClip(clip);
    }
}

Related Tutorials