是否BroadcastReceiver.onReceive总是在UI线程中运行? [英] Does BroadcastReceiver.onReceive always run in the UI thread?
问题描述
在我的应用程序,创建自定义的BroadcastReceiver
并通过 Context.registerReceiver
注册到我的手动语境。我也有一个的AsyncTask
是通过 Context.sendBroadcast
调度通知-意图。的意图是从非UI工作者线程发送,但似乎 BroadcastReceiver.onReceive
(接收所述的Intent)总是在UI线程中运行(这是为我好)。这是保证,我不应该依赖呢?
是否BroadcastReceiver.onReceive总是在UI线程中运行?
是的。
in my App, I create a custom BroadcastReceiver
and register it to my Context manually via Context.registerReceiver
. I also have an AsyncTask
that dispatches notifier-Intents via Context.sendBroadcast
. The intents are sent from a non-UI worker thread, but it seems that BroadcastReceiver.onReceive
(which receives said Intents) always runs in the UI thread (which is good for me). Is this guaranteed or should I not rely on that?
Does BroadcastReceiver.onReceive always run in the UI thread?
Yes.
这篇关于是否BroadcastReceiver.onReceive总是在UI线程中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!