Difference between Handler and AsyncTask

The Handler is associated with the application’s main thread. it handles and schedules messages and runnables sent from background threads to the app main thread.

AsyncTask provides a simple method to handle background threads in order to update the UI without blocking it by time consuming operations.
exapmle:if you want to download something and while downloading you can show ProgressDialog to user without interupting the execution of main ui thread.

Both can be used to update the ui from background thread.
You may consider using handler it you want to post delayed messages or send messages to the MessageQueue in a specific order.


You may consider using AsyncTask if you want to exchange parameters (thus updating UI) between the app main thread and background thread in an easy convinient way.


Comments

Popular Posts