put Text Into Clipboard - Android android.content

Android examples for android.content:Clipboard

Description

put Text Into Clipboard

Demo Code

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);
    }// w ww.ja va 2  s  . c  om

}

Related Tutorials