Вопрос

I have a service running in background. Is there a way for it to intercept global clipboard events?

In particular, I'd like to be notified when the user copies something into the clipboard.

Это было полезно?

Решение

The necessary classes can be found in android.content.ClipboardManager. Use the OnPrimaryClipChangedListener interface to create a listener, and the addPrimaryClipChangedListener() method to set it as a listener.

Please note that it is android.content.ClipboardManager, and not android.text.ClipboardManager, which is the old text-only version which was deprecated in API Level 11.

android.content.ClipboardManager docs

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top