Android Clipboard Paste copyStringToClipboard(Context context, String string, int toastText)

Here you can find the source of copyStringToClipboard(Context context, String string, int toastText)

Description

copy String To Clipboard

Declaration

public static void copyStringToClipboard(Context context,
            String string, int toastText) 

Method Source 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 copyStringToClipboard(Context context,
            String string, int toastText) {
        ClipboardManager clipboardManager = (ClipboardManager) context
                .getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setPrimaryClip(ClipData.newPlainText("", string));
        Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show();
    }//from   w ww .  j a  v a 2  s  .com
}

Related

  1. paste(Context context)
  2. getClipboard(Context context)
  3. paste(Context context)
  4. pasteText(Context context)