Search code examples
androidbroadcastreceiver

Braodcast Receiver in android


I'm confusing about these question.please help me in these question

  1. Many applications registered the broadcast receiver with the same action and one application send the broadcast then what will happen? Does all apps will receive the that intent or only one app will receive the intent ?

  2. can we registered the multiple receivers in the same application?

  3. if we registered the two receivers with same action in the same application then what will happen?


Solution

    1. All receivers will receive the broadcast.

    Broadcast Receivers are designed to provide notification about a single event to multiple receivers.

    There is only one exception to this statement, if a broadcast is an Ordered broadcast, then the broadcast will be propagated sequentially to all receivers one after another(based on priority) and any of the receiver can decide to prevent broadcast from propagating further. The broadcast receiver for SMS is a good example of ordered broadcast.

    1. Yes, multiple receivers can be registered in the same app.

    2. Both the receivers will receive the intent as expected.