Saturday, October 8, 2011

Threads in android UI programming

Two rules:
  1. Do not block the UI thread
  2. Do not access the Android UI toolkit from outside the UI thread
Therefore, only use UI thread message queue to update UI components.

If task is heavy, do the heavy-lift job on another thread and create a callback on UI(main) thread for the worker thread to call back.

A better way is to use AsyncTask straight away.

No comments:

Post a Comment