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(String content, Context context) {
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cmb.setText(content.trim());// ww w  . ja va2s.  c  o  m
}

From source file:Main.java

public static String getCurrentClipContent(Context context) {
    ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    return clipboardManager.getText() == null ? null : clipboardManager.getText().toString();
}

From source file:Main.java

public static String getCopy(Context context) {
    try {/*from w w  w .  ja v  a2  s.  c  o m*/
        ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        return cmb.getText().toString();
    } catch (Exception e) {

    }
    return " ";
}

From source file:Main.java

public static void copyToClipBoard(Context context, CharSequence text) {
    ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboardManager.setText(text);// w w  w  . ja  v  a 2  s . com
}

From source file:Main.java

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

From source file:Main.java

public static void copyToClipboardSupport(Context context, String text) {
    android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context
            .getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setText(text);/* www.  ja  va2s.  c om*/
}

From source file:Main.java

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

From source file:Main.java

public static void setCurrentClipContent(Context context, String clipContent) {
    ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboardManager.setText(clipContent);
}

From source file:Main.java

public static void cleanUpClipboard(Context context) {
    ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData data = ClipData.newPlainText("", "");
    cbm.setPrimaryClip(data);/*w  w w  .  j  a va 2 s  . co m*/
}

From source file:Main.java

public static boolean copy(String content, Context context) {
    try {//from   w w w.j a v a  2s  .  com
        ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        cmb.setText(content.trim());
        return true;
    } catch (Exception e) {

    }
    return false;
}