To get myself a little more familiar with content providers in Android, I\'m making a small clipboard manager app. Its core functionality is to simply add whatever you copy
Put inside your class:
ClipboardManager.OnPrimaryClipChangedListener mPrimaryChangeListener = new ClipboardManager.OnPrimaryClipChangedListener() {
public void onPrimaryClipChanged() {
// this will be called whenever you copy something to the clipboard
}
};
Put this inside onCreate method:
ClipboardManager clipboard = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.addPrimaryClipChangedListener(mPrimaryChangeListener);
That's all. I hope I helped you.
If you are using API level 11 (3.0) or above, then you can use addPrimaryClipChangedListener
which is documented here and there is some example usage here.
What API do you have? This answer: Listener for clipboard content change? seems to suggest that there is a way for android 3.0 and higher, but not lower, unfortunately.
The only other thing I can think of is making a service, querying the clipboard every so often to see if it has changed or has new text. This can be easily done using ClipBoardManager.