1
Reply

What is looper, handler, and message queue in Android?

Satheesh Reddy

Satheesh Reddy

Jan 21, 2014
3.7k
0

    A Looper is a message handling loop: it reads and processes items from a MessageQueue. The Looper class is usually used in conjunction with a LooperThread (a subclass of Thread).A Handler is a utility class that facilitates interacting with a Looper—mainly by posting messages and Runnable objects to the thread's MessageQueue. When a Handler is created, it is bound to a specific Looper (and associated thread and message queue).In typical usage, you create and start a LooperThread, then create a Handler object (or objects) by which other threads can interact with the LooperThread instance. The Handler must be created while running on the LooperThread, although once created there is no restriction on what threads can use the Handler's scheduling methods (post(Runnable), etc.)The main thread (a.k.a. UI thread) in an Android application is set up as a looper thread before your application is created.

    Munesh Sharma
    April 23, 2014
    0