Android Development Flashcards

1
Q

What are the 4 types of app components?

A

Activities.
Services.
Broadcast receivers.
Content providers.

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

What is an Activity lifecycle?

A

https://developer.android.com/reference/android/app/Activity.html

Launched -> onCreate -> onStart -> onResueme -> Running -> onPause -> onStop

onPause -> onResume
onStop -> Killed or onStop -> onRestart

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

What is an Intent?

A

A messaging object you can use to request an action from another app component.

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

What are the three fundamental use cases of an intent?

A
  • starting an activity
  • starting a service
  • delivering a broadcast
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Should an implicit intent be used when starting a service?

A

No

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

Why should you use an explicit intent to start a service?

A

Security reasons, and if an implicit intent is used, your app doesn’t have control of which service will respond to the intent. (API 21+) throws exception if using an implicit intent on call ‘bindService()’

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

What are the main component of building an Intent?

A

Component name, Action, Data, Category, Extras, Flags

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

How do components receive intents?

A

Declaring one or more intent filters for each of the app components with an element in the manifest file.

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

Which three tests must a intent filter pass for implicit intent to use that component?

A

Action test, Category test, Data test

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

Can you declare multiple per component?

A

Yes

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

Which object has a set of query methods that will return all components that accept a particular intents? (by checking components )

A

PackageManager

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

What class serves ass the entry point for an app’s interaction with the user?

A

Activity class

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

Where must you declare activities that will be used in your application?

A

in the manifest file.

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

What is the only required attribute for declaring an activity in the manifest?

A

android:name attribute

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

Which Activity callback method is called when the system first creates the activity?

A

onCreate()

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

What should be performed in the onCreate method of an Activity?

A

Basic application startup logic, (example, bind data, initialize background threads, instantiate class-scope variables).

17
Q

Describe an Activity ‘onStart()’ method?

A

Prepares the activity to enter the foreground and become interactive. (ex. app initializes code that maintains UI, or register a BroadcastReceiver that monitors changes that are reflected in the UI).

18
Q

Describe an Activity ‘onResume()’ method?

A

When this method is executed, activity enters foreground, and is the state in which the app interacts with the users. (Initialize components that are released during ‘onPause()’).

19
Q

When does the Activity leave the onResume state?

A

When the app loses focus.

20
Q

What Activity method is called when the app loses focus?

A

onPause()

21
Q

Describe an Activity ‘onPause()’ method?

A

Execution is very brief, and does not afford enough time to perform save operations or any long operation.

22
Q

What Activity method should be used for ‘heavy-load’ shutdown operations?

A

onStop()

23
Q

Once an Activity is in the ‘onPause()’ state, how long does the activity remain in the ‘onPause()’ state?

A

Until either the activity becomes completely invisible to the user, or if the activity resumes, and the system invokes the ‘onResume()’ method.

24
Q

When an Activity is no longer visible to the user, what method is invoked?

A

onStop()

25
Q

Describe an Activity ‘onStop()’ method?

A

Occurs when an activity becomes invisible to the user, and is the callback to release resources that aren’t needed. (ex. if registered a BroadcastReceiver in onStart() then unregister the receiver in the onStop())

26
Q

What Activity callback method is called after onStop()?

A

onDestroy()

27
Q

Describe an Activity ‘onDestroy()’ method?

A

It is the final call the activity receives. The system invokes this callback because the activity is finishing due to isFinishing() being called or the system destroys the process.

28
Q

What is the purpose of the Activity ‘onDestroy()’ method?

A

To release all resources that have not yet been released.

29
Q

What Activity callback is called when expecting a result from an Intent?

A

onActivityResult(int, int, Intent)

30
Q

Can the android system destroy the process containing your activity to recover memory if the activity is in the Stopped state?

A

Yes, especially when it hasn’t been used in a long time, or if the foreground activity requires more resources.

31
Q

If an Activity is destroyed by the system, and the user navigates back to the activity, how is previously destroyed state get stored?

A

instance state is a collection of key-value pairs stored in a Bundle object

32
Q

What happens to an activity when a configuration change occurs?

A

The activity is destroyed and recreated.

33
Q

What is a Task?

A

It’s a collection of activities that the users interact with when performing a certain job. (ex. using an application)

34
Q

Does the Android system retain state of every activity in the task, when the task is in the background?

A

Yes, unless the android system needs to remove resources for memory.

35
Q

When an activity is destroyed, the system does not retain the activity’s state?

A

True

36
Q

What is the difference in life cycle between AsyncTask and a Loader?

A

An AsyncTask lives as longs as the task lives, the Loader lives as long as the activity that starts it. Loaders are tied to the activity life cycle.

37
Q

How can you make a string resource untranslatable?

A

By setting attribute ‘translatable’ = false

38
Q

Where should your application activities be declared?

A

AndroidManifest.xml file

39
Q

How can you pass multiple parameters to AsyncTaskLoader?

A

By passing the extra parameters to the constructor