Software Development/Tools

[android]ClipboardManager

huiyu 2015. 10. 2. 19:49

public ClipboardManager clipboard;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);

clipboard.removePrimaryClipChangedListener(new ClipboardManager.OnPrimaryClipChangedListener() {
@Override
public void onPrimaryClipChanged() {
//ClipData clipData = clipboard.getPrimaryClip();
ClipData cd = clipboard.getPrimaryClip();
Log.i(TAG, "CLIP LISTEN Remove : " + cd.getItemAt(0).getText());
}
});;

clipboard.addPrimaryClipChangedListener(new ClipboardManager.OnPrimaryClipChangedListener() {
@Override
public void onPrimaryClipChanged() {
//ClipData clipData = clipboard.getPrimaryClip();
ClipData cd = clipboard.getPrimaryClip();
Log.i(TAG, "CLIP LISTEN Changed : " + cd.getItemAt(0).getText());

}
});
}


728x90