简体   繁体   English

剪贴板活动的广播接收器

[英]Broadcast receiver for clipboard activity

Even when the application is not running, I want to grab the content whenever something is copied.即使应用程序没有运行,我也想在复制某些内容时抓取内容。

For example, if the user copies something then, the application will receive a broadcast and start a service (calling an API, in my case).例如,如果用户复制了一些东西,应用程序将接收广播并启动服务(在我的例子中调用 API)。 ALL IN THE BACKGROUND.一切都在后台。 I tried setting a broadcast receiver for USER_PRESENT and managing the clipboard from there, but in vain.我尝试为USER_PRESENT设置广播接收器并从那里管理剪贴板,但徒劳无功。

As of Android 10, this is not possible unless your app currently has input focus (that is, not in the background) or is the user's currently selected keyboard app. 从 Android 10 开始,除非您的应用当前具有输入焦点(即不在后台)或者是用户当前选择的键盘应用,否则这是不可能的。

Because this is a privacy feature, there is, for better or worse, no way around it other than integrating the feature you want to build into a keyboard app.因为这是一项隐私功能,所以无论好坏,除了将您想要构建的功能集成到键盘应用程序中之外,别无他法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM