Android Clipboard Copy set(Context context, String value)

Here you can find the source of set(Context context, String value)

Description

set

Declaration

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public static void set(Context context, String value) 

Method Source Code

//package com.java2s;
import android.annotation.TargetApi;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;

public class Main {
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public static void set(Context context, String value) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ClipboardManager clipboard = (ClipboardManager) context
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clipData = ClipData.newPlainText("text", value);
            clipboard.setPrimaryClip(clipData);
        } else {//from  w w w  . ja  v a  2s .c  o  m

            ClipboardManager clipboard = (ClipboardManager) context
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            clipboard.setPrimaryClip(ClipData.newPlainText(null, value));
        }
    }
}

Related

  1. onCopy(Context context, String content)
  2. copyToClipboard(Context context, String label, String string, int toastMessageId)
  3. copyToClipboard(Context context, String lable, String text)
  4. copyToClipboard(Context context, String lable, String text)
  5. setClipboard(Context context, String text)
  6. setText(final Context context, final CharSequence text)
  7. setText(final Context context, final CharSequence text)
  8. copy(Context context, String content)