Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**
     * Copies text.
     *
     * @param text The actual text we want to copy.
     */
    public static void copyText(Context context, CharSequence text) {
        ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clipData = ClipData.newPlainText("simple text", text);
        clipboardManager.setPrimaryClip(clipData);
    }
}