简体   繁体   English

TimerTask 和广播接收器 onReceive

[英]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.

相关问题 广播接收器onReceive()不起作用 - Broadcast Receiver onReceive() not work 在广播接收器的onReceive中调用通知 - Calling a notification in onReceive of broadcast receiver 广播接收器onReceive在片段中不起作用 - broadcast receiver onReceive not working in the fragment 为什么不调用广播接收器的onreceive()方法? - Why is Broadcast receiver's onreceive() method not invoked? 在广播接收器中接收时重新启动片段活动 - Restarting a fragment activity onreceive in broadcast receiver android广播接收器OnReceive()延迟导致错误 - android broadcast receiver OnReceive() delay causing errors 无法添加窗口 - 令牌null不适用于广播接收器的OnReceive内的应用程序 - Unable to add window — token null is not for an application inside OnReceive of Broadcast Receiver 如何验证来自不同应用程序的广播接收器的 onReceive 方法是否被实际调用? - How can I verify that the onReceive method of a Broadcast Receiver from a different App is actually called? 基本的Android警报应用程序,广播接收器的onReceive()方法未被调用 - Basic Android alarm app, Broadcast Receiver's onReceive() method not being called 如何从广播接收器的onReceive方法内部访问MainActivity findViewById? - How to get access to the MainActivity findViewById from inside a Broadcast Receiver onReceive method?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM