Chapter 15
Dealing with Threads
Ideally, you want your activities to be downright snappy, so your users don't feel that your application is sluggish. Responding to user input quickly (e.g., within in 200 milliseconds) is a fine goal. At minimum, though, you need to make sure you respond within 5 seconds, lest the ActivityManager
decide to play the role of the Grim Reaper and kill off your activity as being nonresponsive.
Of course, your activity might have real work to do, which takes nonnegligible amount of time. This invariably involves the use of a background thread. Android provides a veritable cornucopia of means to set up background threads, yet allow them to safely interact with the UI on the UI thread.
The “safely interact” concept is ...
Get Beginning Android 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.