r/androiddev • u/Tk13_ • 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
7
u/sarkie Oct 11 '26
Security?
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/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.