Networking 2 Flashcards

1
Q

If networking operations are being performed on the UI thread, and the device is rotated, what happens to the networking result?

A

Application state is destroyed and rebuilt, thus the result of the networking operation is interrupted and lost.

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

What is the solution to the configuration changes issue when networking?

A

User a worker thread such as provided by an implementations of Loader.

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

Define what a loader is…

A

A framework component that provides a way to asynchronously load data to an Activity or Fragment.

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

Where does the worker loader thread send the result when finished?

A

Back to the UI thread.

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

What is Loader a subclass of?

A

AsyncTaskLoader

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

Give some examples of where a Loader can pull data from…

A

Database, Website, Content Provider.

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

Who is responsible for creating and destroying the Loader worker thread?

A

The Loader object.

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

What is a Cursor Loader?

A

A loader that specifically gets data from Content Providers.

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

What are the 4 steps for creating and using a Loader?

A

1) Implement a sub-class of Loader and override loadInBackground( ).
2) Create an instance of the Loader in an Activity or Fragment.
3) Register the Loader with the LoaderManager.
4) Implement onLoadFinished( ) to receive the data from the Loader.

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

Define each of the 3 Loader callback methods…

A

onCreateLoader( ) -> Instantiate and return a Loader.
onLoadFinished( ) -> When Loader is finished, move data to the Views.
onLoaderReset( ) -> When Loader is reset, make the data unavailable.

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

What are the 4 steps for implementing AsyncTaskLoader?

A

1) Define the Loader ID.
2) Call initLoader( ) in containers onCreate( ).
3) Create a LoadManager and call getLoadManager( ).
4) Implement the AsyncTaskLoader callback methods.

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

Explain the main difference between Loader and AsyncTaskLoader…

A

Loader has a LoaderManager which automatically Creates and Destroys Loaders. AsyncTaskLoader has to be manually Created and Destroyed.

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