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 String paste(Context context) {
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    String content = cmb.getText().toString().trim();
    return content;
}

From source file:Main.java

public static void copyText(Context context, String text) {
    ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clipData = ClipData.newPlainText("GankLy_copy", text);
    manager.setPrimaryClip(clipData);//from  w  w w  .j  ava 2  s  . c o  m
}

From source file:Main.java

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

From source file:Main.java

public static void copy2clipboard(Context context, String text) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("clip", text);
    cm.setPrimaryClip(clip);/*from  w  w  w . j a v a2  s  . c om*/
}

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);//www.j av a2  s  .  c o  m
}

From source file:Main.java

public static CharSequence getText(Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return clip.getItemAt(0).coerceToText(context);
    }//from ww  w  . ja v  a 2  s. c om
    return null;
}

From source file:Main.java

public static void copy(Context context, String content) {
    ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cmb.setText(content);// ww  w .j a va2s.  c om
}

From source file:Main.java

public static void cpTextToclipoard(Context c, String text) {
    ClipboardManager clipboard = (ClipboardManager) c.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setText(text);//www .  j av a2  s  .  c o m
}

From source file:Main.java

public static void copyToClipboard(Context context, String text) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("copy", text);
    clipboard.setPrimaryClip(clip);/* ww w  .  j a  v a2 s  .c  o m*/
}

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 w  w w .j a  va2  s  .c  o  m
}