Building responsive apps with AsyncTaskLoader
AsyncTaskLoader
is a Loader implementation that uses AsyncTasks
to perform its background work, though this is largely hidden from us when we implement our own subclasses.
We don't need to trouble ourselves with the AsyncTasks
—they are completely hidden by AsyncTaskLoader
—but with what we learned earlier about AsyncTask
, it is interesting to note that tasks are, by default, executed using AsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
to ensure a high degree of concurrency when multiple Loaders are in use.
Note
The AsyncTaskLoader
in the compatibility package (android.support.v4.content
) does not rely on the public AsyncTask
in the platform. Instead, the compatibility package uses an internal ModernAsyncTask
implementation to avoid Android fragmentation. The ModernAsyncTask
creates threads with the name ModernAsyncTask #<N>
.
In the next section we will use AsyncTaskLoader
to load in the background, a currency...