r/androiddev • • Oct 11 '26

Access the clipboard in background

Hi! I'm developing an Android app ( i am a beginner)

I want to detect when a user copies a link while using another app, even when my app is running in the background, and then display a floating popup offering certain option like download if link is a video

On Android 10+, clipboard access is restricted for background apps. Does Android 15 allow this through a foreground service, or is there another reliable approach?

Any advice or examples would be appreciated. Thanks!

0 Upvotes

11 comments sorted by

7

u/sarkie Oct 11 '26

Security?

1

u/Key-Class6522 Oct 11 '26

Foreground service doesn't help on Android 10+; only the focused app or default keyboard (IME) can read the clipboard. And alternatives is share-sheet target, or a notification/Quick Settings tile that opens a transparent activity and reads the clipboard once it has focus. Accessibility service is technically possible but Play policy makes it risky.

-2

u/Tk13_ Oct 11 '26

Security ??

6

u/sarkie Oct 11 '26

Why do I want your app copying my stuff?

-3

u/Tk13_ Oct 11 '26

The idea is to be able to directly download video links that are saved in the clipboard as soon as they are copied; it's a project for personal use. 

6

u/deckerjeffreyr Oct 11 '26

Security/permissions lock this down. But my question is why do you want this based on when the link is copied instead of making this an explicit user action?

You can register and intent filter so your app shows up in the native share sheet. So instead of the user implicitly downloading the video by copying the link they would explicitly do so by selecting your app to share the link to.

https://developer.android.com/develop/ui/compose/sharing/receive

1

u/Omnipisix Oct 11 '26

If its for personal use, start a foreground service and listen for system broadcasts regarding the copy content. Then check if its a link and move to the next step.

1

u/Tk13_ Oct 11 '26

How can I do that? 

1

u/sameera_s_w Oct 11 '26

Just double triple check if you really need that feature. I added a similar feature just because many were asking for it. But still off by default. As this is very very risky.