Example usage for android.text ClipboardManager setText

List of usage examples for android.text ClipboardManager setText

Introduction

In this page you can find the example usage for android.text ClipboardManager setText.

Prototype

public abstract void setText(CharSequence text);

Source Link

Document

Sets the contents of the clipboard to the specified text.

Usage

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 source file:Main.java

public static void copyToSystem(Context context, String content) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cm.setText(content);
}

From source file:Main.java

public static void copy(Context context, String content) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cm.setText(content);
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static void copyText(Context context, String text) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cm.setText(text);
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static void setClipboardText(Context context, CharSequence text) {
    ClipboardManager ClipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipMan.setText(text.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

/**
 * Copy text to clip board/*from w w  w  . ja va  2 s.  com*/
 * @param context
 * @param text
 */
public static void setClipboardText(Context context, String text) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setText(text);
}

From source file:Main.java

public static void copyToClipBoard(Context context, CharSequence text) {
    ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboardManager.setText(text);
}

From source file:Main.java

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

    }
    return false;
}

From source file:Main.java

/**
 * Copy a text to the clipboard./* w ww  .java  2s  . com*/
 * @param context
 * @param text
 * @param toastMessage The message to show in a Toast notification. If empty or null, does not display notification.
 */
public static void copyTextToClipboard(Context context, String text, String toastMessage) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
    clipboard.setText(text);

    if (toastMessage != null && toastMessage.length() > 0) {
        Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show();
    }
}