Search in sources :

Example 26 with ClipboardManager

use of android.content.ClipboardManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CopyablePreference method copyPreference.

public static void copyPreference(Context context, CopyablePreference pref) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    cm.setText(pref.getCopyableText());
    Toast.makeText(context, com.android.internal.R.string.text_copied, Toast.LENGTH_SHORT).show();
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 27 with ClipboardManager

use of android.content.ClipboardManager in project AndroidUtilCode by Blankj.

the class ClipboardUtils method copyUri.

/**
     * 复制uri到剪贴板
     *
     * @param uri uri
     */
public static void copyUri(Uri uri) {
    ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setPrimaryClip(ClipData.newUri(Utils.getContext().getContentResolver(), "uri", uri));
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 28 with ClipboardManager

use of android.content.ClipboardManager in project AndroidUtilCode by Blankj.

the class ClipboardUtils method getIntent.

/**
     * 获取剪贴板的意图
     *
     * @return 剪贴板的意图
     */
public static Intent getIntent() {
    ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return clip.getItemAt(0).getIntent();
    }
    return null;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 29 with ClipboardManager

use of android.content.ClipboardManager in project AndroidUtilCode by Blankj.

the class ClipboardUtils method copyIntent.

/**
     * 复制意图到剪贴板
     *
     * @param intent 意图
     */
public static void copyIntent(Intent intent) {
    ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setPrimaryClip(ClipData.newIntent("intent", intent));
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 30 with ClipboardManager

use of android.content.ClipboardManager in project CustomActivityOnCrash by Ereza.

the class DefaultErrorActivity method copyErrorToClipboard.

private void copyErrorToClipboard() {
    String errorInformation = CustomActivityOnCrash.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText(getString(R.string.customactivityoncrash_error_activity_error_details_clipboard_label), errorInformation);
        clipboard.setPrimaryClip(clip);
    } else {
        //noinspection deprecation
        android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        clipboard.setText(errorInformation);
    }
}
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