Lecture 3 Flashcards

1
Q

What are the four different types of components?

A

Activities - single screen

Services - background processes

Broadcast receivers - to subscribe to events in the android operating system

Content providers - e.g databases

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

What is the point of a component?

A

Entry point through which the system or user can enter the app

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

What are Intents?

A

Allows an app to call a component from another app

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

What is an Activity?

A

Entry point for interacting with the user

Single screen with an interface

Can be launched by other apps is the containing app allows it

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

What interactions between system and app do activities faciliate?

A

Tracking user activity (what they are doing)

Tracking previously used processes and content and allowing user to resume

Allowing apps to flow between each other

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

What is the most important component type?

A

Activity

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

When an Activity is launched, what processes are called?

A

onCreate() -> onStart() -> onResume()

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

When is onPause() called?

A

When the activity needs to pause but still be visible, e.g. a semi transparent dialog or window covers it

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

When a resumed activity is closed, what processes are called?

A

onPause() -> onStop() -> onDestroy()

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

When is an activity stopped?

A

When another Activity is launched. E.g. new window or closing the app

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

What happens to an Activity when the screen is rotated?

A

Activity is destroyed then Recreated

State of any view components is retrieved and re-instantiated though

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

What 6 states can an Activity be in?

A

Created

Started (visible)

Resumed (visible)

Paused (partially visible)

Stopped (hidden)

Destroyed

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

When should you save any important information?

A

Frequently and immediately if possible!

onPause and onStop should be used to save non-critical state info

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

How do apps run with relation to the linux-like architecture of Android?

A

Each app is separate linux user with its own VM. Can only access its own files

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

Which component doesn’t exchange Intents?

A

Content providers

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

Why are intents used instead of direct method calls?

A

Allows other components to be started

access can be controlled by OS

17
Q

Where must all components be registered?

A

AndroidManifest.xml

18
Q

How do you start a new Activity?

A

Define a class that sub-classes Activity

Add some GUI control to invoke from parent Activity

Listen for the relevant GUI event, then launch a new Intent

19
Q

What are the two types of Intent? What’s the difference?

A

Explicit and Implicit

Explicit: specifies exactly which Activity should be started

Implicit: Explains what the activity should do (eg a web browser) - system then finds the most appropriate

20
Q

What is the back stack?

A

Collection of activities that users interact with

Each opened Activity is added to the back stack when it is opened

When the user presses the back button, the Activity is ended and popped off the stack

21
Q

How can you have multiple instances of the same activity within an app on the back stack?

A

if activities in that app can be instantiated from multiple places

22
Q

How can the back stack behaviour be modified?

A

Attributes in <activity> manifest element and flags in startActivity()</activity>

Can do things like clear back stack of all activities from that app except the root activity, or bring forward an existing activity

23
Q
A