| Start |
|---|
| HandlerThreads and communication between Threads As Creating a Handler for the current ThreadCreating a Handler for the main Thread (UI Thread)Send a Runnable from another Thread to the main ThreadCreating a Handler for another HandlerThread and sending events to it |
| Use Handler to create a Timer (similar to javax.swing.Timer) This can be useful if you're writing a game or something that needs to execute a piece of code every a few seconds. Example usage: This code will print "Hello" every second. |
| Using a Handler to execute code after a delayed amount of time Executing code after 1.5 seconds: Executing code repeatedly every 1 second: |
| Stop handler from execution To stop the Handler from execution remove the callback attached to it using the runnable running inside it: RemarksA Handler can be easily used to execute code after a delayed amount of time. It is also useful for executing code repeatedly after a specified amount of time by calling the Handler.postDelayed() method again from within the Runnable's run() method. |
Read Article
https://develop.horje.com/learn/1434/reference