I know that we have 10 seconds to handle an intent; otherwise, watch dog timer will kick in. And its suppose be a light-weight function. So my question is, does the BroadcastReceiver run in the same process as your root activity? Or does it run on Zygote system process?
Creating a BroadcastReceiverThe intent object is passed with all the additional data. A Context object is also available and is used to start an activity or service using context. startActivity(myIntent); or context. startService(myService); respectively.
A BroadcastReceiver object is only valid for the duration of the call to onReceive(Context, Intent) . Once your code returns from this function, the system considers the object to be finished and no longer active.
onReceive. This method is called when the BroadcastReceiver is receiving an Intent broadcast.
Broadcasting Events with IntentsSet the action, data, and category of your Intent in a way that lets Broadcast Receivers accurately determine their interest. In this scenario, the Intent action string is used to identify the event being broadcast, so it should be a unique string that identifi es the event.
So my question is, does the BroadcastReceiver run in the same process as your root activity?
Yes. And, as xandy notes, it also runs on the main application thread. Your BroadcastReceiver
should either do its work very quickly or call startService()
on an IntentService
(or something) that can do long-running work on a background thread.
BTW, I am pleased to see that you have time to spend on Android application development, now that you are no longer busy saving the world. It must be nice to spend time on a hobby and not worry about being shot at, blown up, etc. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With