我有一个功能,每两秒读取一次 Android 剪贴板的内容,并将所有更改与远程服务器通信。
这在应用程序打开时工作正常。但我需要能够在应用程序关闭后继续记录剪贴板更改。
所以我尝试了 IntentService
但它不喜欢长循环。
如何在后台运行我的无限循环?
最佳答案
I have a function that reads the content of the Android clipboard every two seconds and communicates all changes with a remote server.
轮询?你做错了非常。你应该使用 OnPrimaryClipChangedListener相反。
编辑
communicates all changes with a remote server.
我刚刚意识到你基本上在那里做了一些坏事,我有点怀疑你的用户是否知道你真的在监视他们?您的应用程序在 Google Play 中吗?如果是,您的应用程序包 ID 是多少?
关于android - 在 Android 后台运行一个循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31774017/