Example usage for android.content Context CLIPBOARD_SERVICE

List of usage examples for android.content Context CLIPBOARD_SERVICE

Introduction

In this page you can find the example usage for android.content Context CLIPBOARD_SERVICE.

Prototype

String CLIPBOARD_SERVICE

To view the source code for android.content Context CLIPBOARD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.content.ClipboardManager for accessing and modifying the contents of the global clipboard.

Usage

From source file:Main.java

public static void copyToClipboard(Context context, String text) {
    ((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setText(text);
}

From source file:Main.java

public static String paste(Context context) {
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    return cmb.getText().toString().trim();
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static CharSequence getClipboard(Context context) {
    return ((android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).getText();
}

From source file:Main.java

private static ClipboardManager getClipboardManager(Context context) {
    return (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
}

From source file:Main.java

public static boolean checkClipborad(Context context) {
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    return cmb.hasText();
}

From source file:Main.java

public static void copy(Context context, String content) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cm.setText(content.trim());/*from   w  ww . j a v a  2s  . co  m*/
}

From source file:Main.java

public static final int clipboardTextLength(Context context) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    CharSequence text = cm != null ? cm.getText() : null;
    return text != null ? text.length() : 0;
}

From source file:Main.java

public static void copy(Context context, String content) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cm.setText(content);/*w  ww .  j a v a2  s  .  co m*/
}

From source file:Main.java

public static void copyToSystem(Context context, String content) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cm.setText(content);//from   w ww  . j a  v a 2s  .  com
}

From source file:Main.java

public static void copyToClipboard(Context context, String content) {
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cmb.setText(content.trim());//from w  w w. java  2 s  .co m
}