Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clipboard not accessible from background app with Android 10 SDK upgrade

The copy/paste feature used to work in my app. But once I have upgraded my apps SDK to target Android 10, it doesn't get the correct data. Eg. If I copy "Hello" from chrome, open my app and paste it, Hello is pasted. Now if I go to chrome without killing my app and copy "World", open my app and paste, "Hello" is pasted.

There have been some changes related to privacy in Android 10: https://developer.android.com/about/versions/10/privacy/changes#clipboard-data

My onPrimaryClipChanged() callback isn't triggered on Android 10 with my app getting the SDK upgrade as well.

Is there any solution to this, kindly give a suggestion?

like image 565
codeignitor Avatar asked Nov 25 '22 23:11

codeignitor


1 Answers

There's only one solution: asking for permission android.permission.READ_LOGS and then use logcat or dumpsys command to get the clipboard. This permission must be granted via ADB.

like image 89
greywolf82 Avatar answered Dec 04 '22 13:12

greywolf82