Lecture 15: Introduction to Broadcasts Flashcards

1
Q

Broadcasts in Android are a way of ____

A

notifying other applications or activities that some kind of event has taken place

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

The Android system itself uses broadcasts to notify applications when ___

A

system events have taken place

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

Applications may set up ___ to read broadcasts and ___ to send them

A

Applications may set up ___ to read broadcasts and ___ to send them

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

The most common purpose of a broadcast receiver is to receive __ notifications

A

system level

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

Introduction to Broadcasts

A
  • ACTION_BATTERY_LOW
  • ACTION_CHARGING
  • ACTION_HEADSET_PLUG
  • ACTION_USB_ACCESSORY_ATTAHED
  • ACTION_DATE_CHANGED
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write code to declare a broadcast receiver in the app manifest

A

<receiver>
<intent-filter>
<action></action>
</intent-filter>
</receiver>

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

The broadcast receiver takes an ___, which in turn names an __ that we will be “listening” for

A
  • intent filter
  • action
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

____ is required if using external broadccasts, if only listening for internal broadcasts this can be ___

A
  • exported=true
  • false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Once the receiver has been declared in the app manifest, you can make a ___ for the receiver. It overrides one method called onReceive which ___

A
  • Java Class
  • opens an activity and displays a toast popup
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Manifest-declared receivers can ____ when they receier a ___

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

Manifest-declared receivers are always ___ for broadcasts

A

listening

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

_____ receivers cant be turned off and will aways trigger

A

Manifest-declared

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

Receivers are __ on application install and then treated as separate ___ for your application

A
  • registered
  • launching entrypoint
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

When a broadcast is made and caught by the receiver, ___

A

the OnReceive method is called and the broadcast receiver is “active”

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

Once the OnReceive method resolves, the receiver ___

A

returns to its dormant “waiting” state

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

You can declare a broadcast receiver without any manifest entry, this known as a ___, as its registered with the ___

A
  • context-registered receiver
  • current context
17
Q

Context-registered receivers exist only for as long as the ___ exists

A

containing context

18
Q

You can declare a broadcast receiver without any manifest entry, this is known as a ___, as its registered with the ___

A
  • context-registered receiver
  • current context
19
Q

To declare a context-registered receiver, you need to create an instance of the ___ and call the ___ with a ___

A
  • Receiver class
  • registerReceiver()
  • context, the receiver, an intent filter, and an exported flag
20
Q

Both contextual and manifest registered receivers can use the same underlying declared ___ and both will call the overridden ___ method when a ___

A
  • Broadcast Receiver
  • OnReceive()
  • broadcast is received
21
Q

Contextually registered receiver will disappear and ____ when the context disappears, while the manifest registered receiver will ___

A
  • stop listening
  • always listen
22
Q

To close an existing context-registered receiver you call ___ and pass it the ___

A
  • unregisterReceiver()
  • BroadcastReceiver object
23
Q

When closing a context-register receiver, you will close all ___ and ___ of the receiver class that have been registered. You cannot selectively deregister ___ receiver from the ___

A
  • intent filter
  • exported flag versions
  • one
  • underlying class
24
Q

Generally you dont need any ___ to listen to most normal system level broadcasts

A

special permissions

25
Q

The broadcast space should be considered ___

A

global

26
Q

To avoid apps doing malicious ats through sending broadcasts, Android lets you apply __ when receiving or sending broadcasts

A

optional permissions

27
Q

___ can demand the broadcasts have necessary permission, while ___ can demand that receivers have a necessary permission

A
  • Receivers
  • Broadcaster
28
Q

Besides permissions another danger that comes to working with broadcast receivers (particularly manifest-registered receivers) is ___

A

performance

29
Q

If a particular broadcast action has many receivers listening to it that action may result in ___

A

multiple apps being launched at once from those receivers

30
Q

___ receivers are preferred where possible to help limit potential performance issues

A

Context-registered