当前位置: 首页>>代码示例>>Java>>正文


Java ClipboardManager类代码示例

本文整理汇总了Java中android.content.ClipboardManager的典型用法代码示例。如果您正苦于以下问题:Java ClipboardManager类的具体用法?Java ClipboardManager怎么用?Java ClipboardManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClipboardManager类属于android.content包,在下文中一共展示了ClipboardManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMenuItemClick

import android.content.ClipboardManager; //导入依赖的package包/类
@Override
public boolean onMenuItemClick(MenuItem item, LogLine logLine) {
    if (logLine != null) {
        switch (item.getItemId()) {
            case CONTEXT_MENU_COPY_ID:
                ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

                clipboard.setPrimaryClip(ClipData.newPlainText(null, logLine.getOriginalLine()));
                Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
                return true;
            case CONTEXT_MENU_FILTER_ID:

                if (logLine.getProcessId() == -1) {
                    // invalid line
                    return false;
                }

                showSearchByDialog(logLine);
                return true;
        }
    }
    return false;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:LogcatActivity.java

示例2: copyText

import android.content.ClipboardManager; //导入依赖的package包/类
@Override
public void copyText() {
    if (checkNull()) {
        view.showCopyTextError();
        return;
    }

    ClipboardManager manager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
    ClipData clipData = null;
    switch (type) {
        case TYPE_ZHIHU:
            clipData = ClipData.newPlainText("text", Html.fromHtml(title + "\n" + zhihuDailyStory.getBody()).toString());
            break;
        case TYPE_GUOKR:
            clipData = ClipData.newPlainText("text", Html.fromHtml(guokrStory).toString());
            break;
        case TYPE_DOUBAN:
            clipData = ClipData.newPlainText("text", Html.fromHtml(title + "\n" + doubanMomentStory.getContent()).toString());
    }
    manager.setPrimaryClip(clipData);
    view.showTextCopied();

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DetailPresenter.java

示例3: getIntent

import android.content.ClipboardManager; //导入依赖的package包/类
/**
 * 获取剪贴板的意图
 *
 * @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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ClipboardUtils.java

示例4: onTransaction

import android.content.ClipboardManager; //导入依赖的package包/类
private void onTransaction(String hash) {
    hideDialog();
    dialog = new AlertDialog.Builder(this)
            .setTitle(R.string.transaction_succeeded)
            .setMessage(hash)
            .setPositiveButton(R.string.button_ok, (dialog1, id) -> {
                finish();
            })
            .setNeutralButton(R.string.copy, (dialog1, id) -> {
                ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("transaction hash", hash);
                clipboard.setPrimaryClip(clip);
                finish();
            })
            .create();
    dialog.show();
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:18,代码来源:ConfirmationActivity.java

示例5: onLongClick

import android.content.ClipboardManager; //导入依赖的package包/类
@Override
public boolean onLongClick(View v) {
    if (v == mCloseButton) {
        return showAccessibilityToast(v, getResources().getString(R.string.close_tab));
    } else if (v == mCustomActionButton) {
        return showAccessibilityToast(v, mCustomActionButton.getContentDescription());
    } else if (v == mTitleUrlContainer) {
        ClipboardManager clipboard = (ClipboardManager) getContext()
                .getSystemService(Context.CLIPBOARD_SERVICE);
        Tab tab = getCurrentTab();
        if (tab == null) return false;
        String url = tab.getOriginalUrl();
        ClipData clip = ClipData.newPlainText("url", url);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(getContext(), R.string.url_copied, Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:CustomTabToolbar.java

示例6: onBindViewHolder

import android.content.ClipboardManager; //导入依赖的package包/类
@Override
public void onBindViewHolder(CodigoDeBarraAdapter.ViewHolder holder, final int position) {

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ClipboardManager clipboard = (ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Codigo de barras copiado", extractList.get(position).getCodigoDeBarras());
            clipboard.setPrimaryClip(clip);

            Toast.makeText(v.getContext(), "Codigo de barras copiado", Toast.LENGTH_LONG).show();
        }
    });

    holder.bindExtractViewModel(extractList.get(position));
}
 
开发者ID:ViniciusSossela,项目名称:meuboleto,代码行数:17,代码来源:CodigoDeBarraAdapter.java

示例7: TerminalLinesAdapter

import android.content.ClipboardManager; //导入依赖的package包/类
public TerminalLinesAdapter(Activity a, List<TerminalPrintedLine> lines) {
    this.activity = a;
    this.lines = lines;
    inflater = (LayoutInflater) activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    uiHandler = new Handler();
    copyRunnable = new Runnable() {
        @Override
        public void run() {
            clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                if (!copyLine.equals("")) {
                    clipboardManager.setPrimaryClip(ClipData.newPlainText("OneSheeldClipboard", copyLine));
                    Toast.makeText(activity.getApplicationContext(), R.string.terminal_line_copied_toast, Toast.LENGTH_SHORT).show();
                }else
                    Toast.makeText(activity.getApplicationContext(), R.string.terminal_couldnt_copy_empty_line_toast, Toast.LENGTH_SHORT).show();
            }
        }
    };
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:21,代码来源:TerminalLinesAdapter.java

示例8: onCreate

import android.content.ClipboardManager; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    context=getApplicationContext();

    mClipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
    notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    createNotificationChannel();


    listener = new ClipboardManager.OnPrimaryClipChangedListener() {
        public void onPrimaryClipChanged() {
            performClipboardCheck();
        }
    };
}
 
开发者ID:emmanuelkehinde,项目名称:TwittaSave-Android,代码行数:18,代码来源:AutoListenService.java

示例9: getString

import android.content.ClipboardManager; //导入依赖的package包/类
@Override
@JSMethod
public void getString(@Nullable JSCallback callback) {
    Context context = mWXSDKInstance.getContext();
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

    Map<String, Object> map = new HashMap<>(2);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        ClipData.Item item = clip.getItemAt(0);
        CharSequence text = coerceToText(context, item);

        map.put(RESULT, text != null ? RESULT_OK : RESULT_FAILED);
        map.put(DATA, text != null ? text : "");
    } else {
        map.put(RESULT, RESULT_FAILED);
        map.put(DATA, "");
    }

    if (null != callback) {
        callback.invoke(map);
    }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:24,代码来源:WXClipboardModule.java

示例10: setPrimaryClip

import android.content.ClipboardManager; //导入依赖的package包/类
private void setPrimaryClip(final ClipData clipData) {
    try {
        mUiThreadRule.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ClipboardManager clipboardManager =
                        (ClipboardManager) InstrumentationRegistry.getTargetContext().getSystemService(CLIPBOARD_SERVICE);
                clipboardManager.setPrimaryClip(clipData);
            }
        });
        // ensure clipboard listener has time to react to the changes
        // so that subsequent calls can verify what the listener has done.
        delay(90);
    } catch (Throwable t) {
        fail("Unexpected error in setting clipboard. " + t.getMessage());
    }
}
 
开发者ID:orionlee,项目名称:aDictOnCopy,代码行数:18,代码来源:DictionaryOnCopyServiceTest.java

示例11: paste

import android.content.ClipboardManager; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void paste() {
    ClipboardManager clipboard = (
            ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    //noinspection StatementWithEmptyBody
    if (clipboard.getText() == null || clipboard.getText() == "") {
        //nothing to paste
    }
    if (!clipboard.hasText()) {
        return;
    }
    if (getSelectionEnd() > getSelectionStart()) {
        getText().replace(getSelectionStart(), getSelectionEnd(), clipboard.getText());
    } else {
        getText().replace(getSelectionEnd(), getSelectionStart(), clipboard.getText());
    }
}
 
开发者ID:Light-Team,项目名称:ModPE-IDE-Source,代码行数:19,代码来源:LModEditor.java

示例12: ua

import android.content.ClipboardManager; //导入依赖的package包/类
public void ua()
   {
EditText et=(EditText) findViewById(R.id.mainEditText1);
String os =et.getText().toString();
char[] a = os.toCharArray();
StringBuffer b = new StringBuffer("");
String mo ="妮̶"; 
for (int i=0;i < a.length;i++)
{
    b.append(mo.replace('妮', a[i])) ;
    ClipboardManager manager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    manager.setText(b);
}
TextView t=(TextView) findViewById(R.id.mainTextView1);
t.setText(b);
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:17,代码来源:gifa.java

示例13: onOptionsItemSelected

import android.content.ClipboardManager; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.fenlei_share:
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, url);
            startActivity(Intent.createChooser(intent, getTitle()));
            break;
        case R.id.fenlei_web_open:
            Intent intent1 = new Intent();
            intent1.setAction(Intent.ACTION_VIEW);
            intent1.setData(Uri.parse(url));
            startActivity(intent1);
            break;
        case R.id.fenlei_copy_link:
            ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clipData = ClipData.newRawUri("label", Uri.parse(url));
            clipboardManager.setPrimaryClip(clipData);
            Snackbar.make(mWebView, "已复制到黏贴版", Snackbar.LENGTH_SHORT).show();
            break;
    }
    return true;
}
 
开发者ID:struggledhard,项目名称:USay,代码行数:26,代码来源:WebViewFenLeiActivity.java

示例14: copy

import android.content.ClipboardManager; //导入依赖的package包/类
/**
 * 实现文本复制功能
 */
public static void copy(String content, Context context) {
    if (context == null || content == null) {
        return;
    }
    // 得到剪贴板管理器
    ClipboardManager cmb = (ClipboardManager) context
            .getSystemService(Context.CLIPBOARD_SERVICE);
    if (cmb == null) {
        return;
    }
    try {
        cmb.setPrimaryClip(ClipData.newPlainText(null, content.trim()));
    } catch (Exception e) {
        LogUtils.e(e);
    }
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:20,代码来源:ClipboardUtil.java

示例15: onTouch

import android.content.ClipboardManager; //导入依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
	if (mSearch.getCompoundDrawables()[2] != null) {
		boolean tappedX = event.getX() > (mSearch.getWidth()
				- mSearch.getPaddingRight() - mIcon.getIntrinsicWidth());
		if (tappedX) {
			if (event.getAction() == MotionEvent.ACTION_UP) {
				if (mSearch.hasFocus()) {
					ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
					ClipData clip = ClipData.newPlainText("label", mSearch.getText()
							.toString());
					clipboard.setPrimaryClip(clip);
					Utils.showToast(
							mActivity,
							mActivity.getResources().getString(
									R.string.message_text_copied));
				} else {
					refreshOrStop();
				}
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:27,代码来源:BrowserActivity.java


注:本文中的android.content.ClipboardManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。