Mostly time service run independently in android application without communicating to Activity. But in some cases it become necessary to communicate to activity. Then we have to use Broadcast Receiver to communicate between Activity and services.
Definition
A broadcast receiver is an Android component which allows to register for system or application events. All registered receivers for an event will be notified by Android once this event happens.
Implementation
A Broadcast Receiver extends theBroadcastReceiver class and which is registered as a receiver in an Android Application via the AndroidManifest.xml file(or via code).
Alternatively to this static registration, you can also register a Broadcast Receiver dynamically via the Context.registerReceiver() method.
If the event for which the Broadcast Receiver has registered it receives a Broadcast Intents from the Android system in it's onReceive()method.
No comments:
Post a Comment