Here, I post stuff that i have got chance to explore. I put in the links to the articles that i find most suitable, and as i explore the topic more i add my own comments as well.
Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts
Saturday, 7 April 2012
How to access the android UI thread from other threads
Android offers several ways to access the UI thread from other threads. You may already be familiar with some of them but here is a comprehensive list:
When using a handler, you can pass a single object as part of the Message to the Handler using msg.obj field.Source: http://developer.android.com/resources/articles/painless-threading.html
Andorid Service vs AsyncTask vs Handler
- A service is an Android component that lives independently from any other components. Activities may come and go, but services can stick around, if you wish. They serve a number of roles, from managing state that multiple activities rely upon to serving as cron jobs to handling longer app widget updates.
AsyncTaskis a class that arranges to do some work off the main application thread. From the implementer and user of theAsyncTask, how it performs that bit of magic is not generally important. In reality, it uses a thread pool and work queue.AsyncTaskuses aHandlerto help arrange for select bits of work to be done on the main application thread (e.g., notifying the user of progress updates).Handleris a class that is tied tightly into the message queue and loop that forms the backbone of the main application thread. The primary purpose of aHandlerin application code is to arrange for messages to be sent from background threads to the main application thread, mostly to arrange for updates to the UI, which cannot be done from background threads.
Subscribe to:
Posts (Atom)