4
How to perform an action whenever someone copies some text in Keyboard android? And would have to use a service to leave running all the time?
4
How to perform an action whenever someone copies some text in Keyboard android? And would have to use a service to leave running all the time?
3
You’re looking for the method addPrimaryClipChangedListener
of ClipboardManager
. It takes as parameter one ClipboardManager.OnPrimaryClipChangedListener
.
Assuming you’re familiar with Listeners, the code looks something like this:
final ClipboardManager gerenciadorDeAreaDeTransferencia =
(ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
gerenciadorDeAreaDeTransferencia.
addPrimaryClipChangedListener(new OnPrimaryClipChangedListener() {
@Override
public void onPrimaryClipChanged() {
// seu código
}
}
);
Note that this only works from API 11.
About making it work in the background, you will probably depend on a service, yes, but the details of this are subject to another question.
That’s right, I was already using Clipboardmanager and Clipdata, but I didn’t see the listeners, went unnoticed
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
What kind of action would be performed?
– gato
take the copied text and register it in a @Denercarvalho sqlite database
– felipe.rce