This project is intended to demo the concepts of Threads and Processes in Android. The wrong and right ways of coding computationally intensive or latency heavy tasks.
Andoid UI toolkit is not thread-safe. So, you must not manipulate your UI from a worker thread—you must do all manipulation to your user interface from the UI thread. Thus, there are simply two rules to Android's single thread model:
- Do not block the UI thread
- Do not access the Android UI toolkit from outside the UI thread
- View.post(Runnable) or View.postDelayed(Runnable, long) [see Alternative1Activity.java, Line 48]
- Activity.runOnUiThread(Runnable) [see Alternative2Activity.java, Line 48]
- Handler [see Alternative3Activity.java, Line 52]
- AsyncTask (This one is ideal) [see BetterAlternativeActivity.java, Line 44]
- Develop > API Guides > Processes and Threads
- The following services can be used to fetch Random Pictures (They are called as Placeholder Image Sites, primarily for help to Designers :)