Android Explain Looper, Handler and Handler Thread.

Prachi Rane
May 3, 2024

--

Handler provides just a way to execute some code on the UI thread from the Background/Worker thread. But Handler is not limited to providing access to UI thread only.

To understand Handler more, let’s understand its components: Thread and Looper.

Threads in Android apps start executing their code block written in the run() method and then get destroyed.

But if we want to keep this thread running and send some data or messages to the thread then we use Looper. Looper gives the ability to thread to keep it running in a loop with its own MessageQueue.

UI Thread has a looper created by the Android system.

The background thread doesn’t have a looper if we need looper for background work then we can create it.

--

--

Prachi Rane
0 Followers

Android App Developer with 6 years of experience in Kotlin and Java