copy To Clipboard And Later - Android Android OS

Android examples for Android OS:Clipboard

Description

copy To Clipboard And Later

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull;

public class Main {
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private static void copyToClipboard11AndLater(@NonNull Context context,
            @NonNull String toCopy) {
        android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context
                .getSystemService(Context.CLIPBOARD_SERVICE);
        android.content.ClipData clip = android.content.ClipData
                .newPlainText("Copied Text", toCopy);
        clipboard.setPrimaryClip(clip);/*from  w w w.  j ava 2 s  . c  o m*/
    }
}

Related Tutorials