GetContactsTask Subclass of AsyncTask
Nested class GetContactsTask
(Fig. 8.30) extends class AsyncTask
. The class defines how to interact with the DatabaseConnector
(Section 8.9) to get the names of all the contacts and return the results to this Activity
’s GUI thread for display in the ListView
. AsyncTask
is a generic type that requires three type parameters:
• The variable-length parameter-list type for AsyncTask
’s doInBackground method (lines 103–108)—When you call the task’s execute
method, doInBackground
performs the task in a separate thread. We specify Object
as the type parameter and pass null
as the argument to the AsyncTask
’s execute
method, because GetContactsTask
does not require additional data to perform its task.
• The variable-length ...
Get Android™ How to Program, Second Edition 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.