Thursday, 15 January 2015

What do you understand by Handlers in Android ?

* A Handler is a mechanism to drop a message on the main queue (more precisely, the queue attached to the thread on which the handler is instantiated) so that the message can be processed at a later point in time by the main thread.

* The message that is dropped has an internal reference pointing to the handler that dropped it.

* When the main thread gets around to processing that message, it invokes the handler that dropped the message through a callback method on the handler object.This callback method is called handleMessage.

* The Key players that work together when we talk about handlers are :

- Main thread.

- Main thread queue.

- Handler.

- Message.

No comments:

Post a Comment