
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
How to send messages or runnable objects from the main thread to a background thread in android. The background thread doesn't have its own message queue, so we create a looper instance for it and a handler within the run() method of the background thread. The handler instance is then associated with the looper instance. To send a message from the main thread to the background thread, we first obtain a reference to the handler of the background thread and then give the message to the handler, which will post it to the message queue of the background thread. Creating a looper for the background thread is necessary to complete these steps.
Typology: Exams
1 / 1
This page cannot be seen from the preview
Don't miss anything!
Generally Background thread does not have its own message queue ..so we create looper instance for that background thread which maintains messagequeue then we create instance of Handler within run() of background thread and that handler instance implicitly gets associated with thread that is creating it.
Now that created handler instance is associated with looper instance.
If we want to send message from Main thread to Background Thread