O'Reilly logo

Asynchronous Android by Steve Liles

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 about the AsyncTasks—they are completely hidden by AsyncTaskLoader—but with what we learned earlier about AsyncTask, it is interesting to note that tasks are executed using AsyncTask.THREAD_POOL_EXECUTOR to ensure a high degree of concurrency when multiple Loaders are in use.

Loader is generically typed so, when we implement it, we need to specify the type of object that it will load—in our case android.graphics.Bitmap:

public class ThumbnailLoader extends AsyncTaskLoader<Bitmap> {
    // ...
}

The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required