copy text To Clip Board - Android Android OS

Android examples for Android OS:Clipboard

Description

copy text To Clip Board

Demo Code


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

import android.widget.Toast;

public class Main {
    public static void copyToClipBoard(Context context, String text,
            String success) {/*w w  w .  ja  va2  s . c om*/
        ClipData clipData = ClipData.newPlainText("girl_copy", text);
        ClipboardManager manager = (ClipboardManager) context
                .getSystemService(Context.CLIPBOARD_SERVICE);
        manager.setPrimaryClip(clipData);
        Toast.makeText(context, success, Toast.LENGTH_SHORT).show();
    }
}

Related Tutorials