What is a Handler class in Android?
Handlers classes are used to Handle the execution of triggers. If you are working on custom application development on force.com or customizing salesforce to do event-driven updates, you will end up writing quite a few triggers and in some cases more than one trigger on the same object.
A Handler object takes log messages from a Logger and exports them. It might for example, write them to a console or write them to a file, or send them to a network logging service, or forward them to an OS log, or whatever. A Handler can be disabled by doing a setLevel(Level.
Android handles all the UI operations and input events from one single thread which is known as called the Main or UI thread. Android collects all events in this thread in a queue and processes this queue with an instance of the Looper 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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With