Access clipboard data in the background service in Android 10 (Q)

Android 10 kills Clipboard manager for background Apps

CodingwithSaud
2 min readNov 19, 2020

Recently I was working on my Translator app, I implemented the feature which shows a home screen widget when users copy text from any other app, and this feature was successfully implemented in all Android versions less the Android 10. I didn’t succeed in getting the text from clipboard or clipboard manager in android 10 programmatically.

Actually, I was using the background service to listen to the clipboard copy event.

I used the following code to detect the clipboard copy listener

  1. Create a new service and past this code in the onCreate method

2) Then this code in the service class

After doing many types of research from many resources I come to the result that google removed the access of clipboard text for background services or for apps that are copying the text from the background. As Google mentions below.

So still we can access the clipboard data in Android 10 in the Main thread of the Android apps. So we can get a text from the clipboard in our Activity in particularly when the user interacts with UI like when the user clicks on the button in the activity then we can get the text using the clipboard manager in Android 10(Q) programmatically.

--

--