Reader small image

You're reading from  Asynchronous Android Programming - Second Edition

Product typeBook
Published inJul 2016
Reading LevelBeginner
PublisherPackt
ISBN-139781785883248
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Steve Liles
Steve Liles
author image
Steve Liles

Steve Liles is a self-confessed geek and has been an Android fan since the launch day of the G1. When he isn't at work building publishing systems and apps for newspapers and magazines, you'll find him tinkering with his own apps, building 3D printers, or playing RTS games. He is currently working with a start-up to build an advertising system that links the print and digital worlds using computer vision on Android and iOS devices.
Read more about Steve Liles

Right arrow

Applications of Loader


The obvious applications include reading any kind of data from files or databases local to the device, or Android content providers, as we've done in the examples in this chapter.

One strong advantage of Loaders over direct use of AsyncTask is that their lifecycle is very flexible with respect to the Activity and Fragment lifecycles. Without any extra effort we can handle configuration changes such as an orientation change.

We can even start loading in one Activity, navigate through the app, and collect the result in a completely separate Activity, if that makes sense for our app.

In some ways, this decoupling from the Activity lifecycle makes Loader a better candidate than AsyncTask to perform network transfers such as HTTP downloads; however, they require more code and still aren't a perfect fit.

The framework is very powerful for managing asynchronous data loading; however, it does not provide a mechanism to show the loading progress, as we have on the AsyncTask framework...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Asynchronous Android Programming - Second Edition
Published in: Jul 2016Publisher: PacktISBN-13: 9781785883248

Author (1)

author image
Steve Liles

Steve Liles is a self-confessed geek and has been an Android fan since the launch day of the G1. When he isn't at work building publishing systems and apps for newspapers and magazines, you'll find him tinkering with his own apps, building 3D printers, or playing RTS games. He is currently working with a start-up to build an advertising system that links the print and digital worlds using computer vision on Android and iOS devices.
Read more about Steve Liles