Android 复制到剪贴板的方法

// 3.O以后和3.0以前,复制到剪贴板的方法不一致
        if (DevUtil.hasHoneycomb()) {
            ClipboardManager copy = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
            copy.setPrimaryClip(ClipData.newPlainText("url", content));
        } else {
            android.text.ClipboardManager copy = (android.text.ClipboardManager) mContext
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            copy.setText(content);
        }

        showToast(mContext.getString(R.string.pub_share_platform_copy_url_success));

 

posted @ 2015-10-13 09:23  百晓生  阅读(569)  评论(0编辑  收藏  举报