What is Handler class?

A handler is basically a message queue. You post a message to it, and it will eventually process it by calling its run method and passing the message to it. Since these run calls will always occur in the order of messages received on the same thread, it allows you to serialize events.


As given in Handler documentation on android dev site, there are two main uses for a Handler:

  1. To schedule messages and runnables to be executed as some point in the future; and
  2. To enqueue an action to be performed on a different thread than your own.