4. Advanced Threading Techniques

This chapter showcases a collection of threading techniques that are provided by the Android Framework to make the usage of threads easier and more secure. First, the Loaders API that comes with the support package is demonstrated. Next, the AsyncTask API is shown, which is a very flexible and powerful replacement for raw Java threads. Then the ways of using inter-process communication on Android are discussed.

Loaders

Typical usage scenarios for threads are the moments in an application lifecycle when screens are initialized with data from databases or caches. If done on the main thread, these operations can block the loading of the layout itself and leave the user staring at a blank screen for a couple of seconds. ...

Get The Android™ Developer’s Cookbook: Building Applications with the Android SDK, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.