[英]TimerTask and Broadcast Receiver onReceive
I have multiple times onReceive triggered with different data for intent during each occurence.在每次发生期间,我有多次 onReceive 触发了不同的意图数据。 I need to combine all the intent data into a list of intents inside a background thread.
我需要将所有意图数据组合到后台线程内的意图列表中。 How can I achieve this?
我怎样才能做到这一点? I tried using timer task, but couldn't achieve the same.
我尝试使用计时器任务,但无法实现。 Is there any other way?
还有其他方法吗? Kindly explain with examples as I don't have much knowledge on background thread BlockingQueue cannot be used as It will block UI thread for a long time is what I saw in stackoverflow.
请举例说明,因为我对后台线程了解不多,不能使用 BlockingQueue,因为它会长时间阻塞 UI 线程,这是我在 stackoverflow 中看到的。
You could use AsyncTask and do you operations in the doInBackground()-method.您可以使用 AsyncTask 并在 doInBackground() 方法中进行操作。 Check out Android's AsyncTask documentation .
查看Android 的 AsyncTask 文档。 (Was deprecated in Android R, however)
(在 Android R 中已弃用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.