Component- 3.Broadcast Receivers
Broadcast Receivers
- A broadcast/Intent receiver is a component that receives and reacts to broadcast announcements.
- Applications can also initiate broadcasts
- They also respond to a system-wide announcement of an event
- Announcements can come : internally, say from OS – Battery Low / timezone change or from other applications.
- Broadcast receiver components are used to listen to the announcements made by other application components through intents.
- Broadcast receivers can respond to the announcements in following ways:
- Starting an activity
- Starting a service
- Alert using notifications
- Broadcast receivers does not have any user interface.
- They also respond to a system-wide announcement of an event
- Announcements can come as
internally, say from OS – Battery Low / timezone change or from other applicationsThere are two major classes of broadcasts that can be received:
- Normal broadcasts (sent with
Context.sendBroadcast
) are completely asynchronous. All receivers of the broadcast are run in an undefined order, often at the same time. This is more efficient, but means that receivers cannot use the result or abort APIs included here. - Ordered broadcasts (sent with
Context.sendOrderedBroadcast
) are delivered to one receiver at a time. As each receiver executes in turn, it can propagate a result to the next receiver, or it can completely abort the broadcast so that it won't be passed to other receivers. The order receivers run in can be controlled with theandroid:priority
attribute of the matching intent-filter; receivers with the same priority will be run in an arbitrary order.
Comments
Post a Comment
Please post comments here:-)