Skip to Content
Pro Android Apps Performance Optimization
book

Pro Android Apps Performance Optimization

by Hervé Guihot
January 2012
Intermediate to advanced content levelIntermediate to advanced
282 pages
7h 4m
English
Apress
Content preview from Pro Android Apps Performance Optimization

Handlers and Loopers

Android defines two classes in the android.os package that will often be the cornerstones of the interthread communication in your multithreaded applications:

  • Handler
  • Looper

While creating an AsyncTask object hides the Handler and Looper details from you, in some cases you need to use handlers and loopers explicitly, for example when you need to post a Runnable to a thread other than the main thread.

Handlers

Listing 5–2 gave you a glimpse of how the Handler and Looper work together: you use a Handler object to post a Runnable in a Looper's message queue. Your application's main thread already has a message queue, so you don't have to create one explicitly. However, the threads you create do not come automatically with ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Android High Performance Programming

Android High Performance Programming

Enrique López Mañas, Diego Grancini
Pro Android Graphics

Pro Android Graphics

Wallace Jackson

Publisher Resources

ISBN: 9781430239994Purchase book