user2103008
user2103008

Reputation: 524

How does a Broadcastreceiver work?

I'm new to Android and want to know how it works. Specifically, does each broadcastreceiver run in a separate thread ?

If not so, say a computationally intensive task is going on outside the receiver and simultaneously in a separate application, broadcasts are being sent for the receiver. Then, does the receiver have some sort of queue to manage incoming requests when the intensive task gets over ? Or does it ignore the requests ?

To be more specific, I'm writing an application which sends data to a server, gets a response and monitors battery life. I'm a bit skeptical about the broadcastreceiver monitoring battery life executes the moment it's sent an intent about battery level changed.

Thanks for the input in advance.

Upvotes: 1

Views: 1536

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007322

Specifically, does each broadcastreceiver run in a separate thread ?

No. onReceive() is always called on the process' main application thread.

Then, does the receiver have some sort of queue to manage incoming requests when the intensive task gets over ?

Your "computationally intensive task" should not be running on the main application thread and therefore should not interfere with the timely receipt of broadcasts.

Upvotes: 1

Related Questions