Broadcasts Flashcards

1
Q

When are broadcasts sent?

A

● These broadcasts are sent when an event of interest
occurs, e.g., the Android system sends broadcasts when various system events occur, such as when the system boots up or the device starts charging.
● Individual applications can also send custom broadcasts, for example, to notify other applications of something that
they might be interested in (e.g, when some new data has been downloaded).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Discuss subscription to broadcasts

A

● Applications can register to receive specific broadcasts.
● When a broadcast is sent, the system automatically routes broadcasts to applications that have subscribed to receive that particular type of broadcast.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Discuss system broadcasts

A

Android has a number of system broadcasts sent with some key events happening in the system such as battery charging, airplane mode, reduced charge,
etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 2 main ways of receiving broadcasts?

A

– Manifest-declared receivers
– Context-registered receivers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe Manifest-declared Receivers

A

● If you declare a broadcast receiver in your manifest, the system launches your application (if it is not already running) when the broadcast is sent.
● The system package manager registers the receiver when the application is installed.
● The receiver then becomes a separate entry point into your application which means that the system can start the application and deliver the broadcast if the application is not currently running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe Context-registered Receivers

A

● Context-registered receivers receive broadcasts as long as their registering context is valid, e.g, if you register within an Activity context, you receive broadcasts as long as the
activity is not destroyed.
● If you register with the Application context, you
receive broadcasts as long as the application is running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the three ways of sending broadcasts

A

sendOrderedBroadcast(Intent, String)
sendBroadcast(Intent):
LocalBroadcastManager.sendBroadcast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Discuss sendOrderedBroadcast(Intent, String):

A

● This method sends broadcasts 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 the
android:priority attribute of the matching intent-filter; receivers with the same priority will be run in an arbitrary order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Discuss sendBroadcast(Intent):

A

● This method sends broadcasts to all receivers in an undefined order. This is called a Normal Broadcast.
● This is more efficient, but means that receivers cannot read results from other receivers, propagate data received from the broadcast, or abort the broadcast.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Discuss LocalBroadcastManager.sendBroadcast

A

● This method sends broadcasts to receivers that are in the same application as the sender.
● If you don’t need to send broadcasts across applications, use local broadcasts.
● The implementation is much more efficient (no interprocess communication needed) and you don’t need to worry about any security issues related to
other applications being able to receive or send your broadcasts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly