如何检测复制事件并为其添加额外的文本?
我试过这样做:
//onCreate:
ClipboardManager clipboard = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.addPrimaryClipChangedListener(mPrimaryChangeListener);
//End onCreate:
ClipboardManager.OnPrimaryClipChangedListener mPrimaryChangeListener =
new ClipboardManager.OnPrimaryClipChangedListener() {
public void onPrimaryClipChanged() {
ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
String clipText = clipBoard.getPrimaryClip().getItemAt(0).getText().toString();
ClipData clip = ClipData.newPlainText("label",clipText +" by Jhon");
clipBoard.setPrimaryClip(clip);
}
};
但它并没有什么不同,它只复制所选文本而没有" by John"
符号。