Does BroadcastReceiver.onReceive always run in the UI thread?

后端 未结 5 1372
星月不相逢
星月不相逢 2020-11-28 02:35

In my App, I create a custom BroadcastReceiver and register it to my Context manually via Context.registerReceiver. I also have an AsyncTask<

5条回答
  •  无人及你
    2020-11-28 03:22

    Since you dynamically register the receiver you can specify that another thread (other than the UI thread) handles the onReceive(). This is done through the Handler parameter of registerReceiver().

    That said, if you did not do specify another Handler, it will get handled on UI thread always.

提交回复
热议问题