Menu

1 / 2

What Android's clipboard rules taught me while building a clipboard manager

DEV Community: kotlin·DangNH Studio·1 day ago
#QuoVB5n0
#devtokotlin#devto#dev#android#clipboard
Long article (1065 words) — no AI summary yet.
Reading 0:00
15s threshold

I'm a solo developer. Over the last year I've published a few dozen small Android utilities under the name DangNH Studio, and one of them is a clipboard manager called ClipFox. I assumed it would be the easy one. A clipboard is one system service, how hard can it be?

It turned out to be the app where Android's privacy changes affected my design the most. Here is what I learned, in the order it surprised me.

1. The background listener stopped working

The classic clipboard manager idea is this: register a listener, record every copy, show the history later.

val cm = getSystemService ( ClipboardManager :: class . java ) cm . addPrimaryClipChangedListener { val text = cm . primaryClip ? . getItemAt ( 0 ) ? . coerceToText ( this ) saveToHistory ( text ) }

Enter fullscreen mode

Exit fullscreen mode

On Android 9 and below this worked from a background service.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.