Randon
Randon

Reputation: 81

How BroadcastReceiver is different from Intent

Hello I see contradicting definitions. Android experts, can you explain this to me please?

1) If BroadCastReceiver is a component in android that responds to intents, then I can as well register an filter for activity in androidManifest xml file and have it do my job based on intent like battery low, no network, orientation change etc. these are intents I might be interested to react in my code.

2) Why register whole another filter for BroadcastReceiver in androoidManifest.xml and perform action at onReceive() inside the BCRCVR class?

3.Can we really perform intent driven operations in an activity? yes right?

Upvotes: 0

Views: 159

Answers (1)

Konstantin Milyutin
Konstantin Milyutin

Reputation: 12366

I guess the title should be "How BroadcastReceiver is different from Activity". In my opinion, Broadcast receiver is independent unit, because sometimes you don't want the system to create a new Activity object just to handle arrived intent. Moreover, you don't your activity to be shown. Broadcast receivers are independent and can be used outside any Activity. Activity is more about user interface and broadcast is about handling events.

Upvotes: 1

Related Questions