Search in sources :

Example 81 with ClipboardManager

use of android.content.ClipboardManager in project qksms by moezbhatti.

the class MessageUtils method copyToClipboard.

public static void copyToClipboard(Context context, String str) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setPrimaryClip(ClipData.newPlainText(null, str));
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 82 with ClipboardManager

use of android.content.ClipboardManager in project android-common by litesuits.

the class ClipboardUtil method copyToClipboard.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void copyToClipboard(Context context, String text) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setPrimaryClip(ClipData.newPlainText(null, text));
}
Also used : ClipboardManager(android.content.ClipboardManager) TargetApi(android.annotation.TargetApi)

Example 83 with ClipboardManager

use of android.content.ClipboardManager in project android-common by litesuits.

the class ClipboardUtil method getText.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static String getText(Context context, int index) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > index) {
        return String.valueOf(clip.getItemAt(0).coerceToText(context));
    }
    return null;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData) TargetApi(android.annotation.TargetApi)

Example 84 with ClipboardManager

use of android.content.ClipboardManager in project android-common by litesuits.

the class ClipboardUtil method getLatestText.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static String getLatestText(Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return String.valueOf(clip.getItemAt(0).coerceToText(context));
    }
    return null;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData) TargetApi(android.annotation.TargetApi)

Example 85 with ClipboardManager

use of android.content.ClipboardManager in project Reader by TheKeeperOfPie.

the class EventListenerBase method copyText.

@Override
public void copyText(CharSequence text) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText(context.getString(R.string.comment), text);
    clipboard.setPrimaryClip(clip);
    toast(context.getString(R.string.copied));
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Aggregations

ClipboardManager (android.content.ClipboardManager)125 ClipData (android.content.ClipData)82 Intent (android.content.Intent)17 View (android.view.View)15 TextView (android.widget.TextView)13 Context (android.content.Context)10 Paint (android.graphics.Paint)9 DialogInterface (android.content.DialogInterface)7 Bundle (android.os.Bundle)7 AlertDialog (android.support.v7.app.AlertDialog)7 Editable (android.text.Editable)7 TextPaint (android.text.TextPaint)7 ImageView (android.widget.ImageView)6 TargetApi (android.annotation.TargetApi)5 Spanned (android.text.Spanned)5 AlertDialog (android.app.AlertDialog)4 Uri (android.net.Uri)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Drawable (android.graphics.drawable.Drawable)3 MenuItem (android.view.MenuItem)3