copy Into Clipboard - Android android.content

Android examples for android.content:Clipboard

Description

copy Into Clipboard

Demo Code

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;

public class Main {

  public static void copyIntoClipboard(String value, Context context) {
    copyIntoClipboard("clipboardItem", value, context);
  }//from   ww w. ja  v  a2 s .co  m

  public static void copyIntoClipboard(String label, String content, Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText(label, content);
    clipboard.setPrimaryClip(clip);
  }

}

Related Tutorials