Android的股票网页浏览器的剪贴板钩子

时间:2011-03-06 14:01:20

标签: android browser clipboard

你知道有什么方法可以挂钩Android的股票网页浏览器,这样我就可以选择,复制和播放以编程方式粘贴网页内容?

2 个答案:

答案 0 :(得分:2)

库存中的所选文本Android浏览器被复制到ClipBoard。使用ClipBoardManager获取复制的文本(如下所示)。

 ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
 String text = clipboard.hasText() ? clipboard.getText().toString() : "";

答案 1 :(得分:0)

ClipboardManager clipboardManager = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
if (clipboardManager.hasText()) {
    Toast.makeText(getApplicationContext(),
        "Clipboard Text = " + clipboardManager.getText().toString(),
        Toast.LENGTH_LONG).show();
    clipboardManager.setText(null);
} else {
    Toast.makeText(getApplicationContext(),
        "No Content in Clipboard. So set some text in clipboard",
        Toast.LENGTH_LONG).show();
    clipboardManager.setText("AndroidPeople.com");
    Toast.makeText(getApplicationContext(),
        "Clipboard Text = " + clipboardManager.getText().toString(),
        Toast.LENGTH_LONG).show();
}