put Text Into Clipboard - Android Android OS

Android examples for Android OS:Clipboard

Description

put Text 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 putTextIntoClipboard(Context context, String text) {

        ClipboardManager clipboardManager = (ClipboardManager) context
                .getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clipData = ClipData.newPlainText("copy text", text);
        clipboardManager.setPrimaryClip(clipData);
    }//ww w . j a  v  a  2  s .c om
}

Related Tutorials