ContactListFragment Overridden Method onResume

Fragment lifecycle method onResume (Fig. 8.29) creates and executes an AsyncTask (line 93) of type GetContactsTask (defined in Fig. 8.30) that gets the complete list of contacts from the database and sets the contactAdapter’s Cursor for populating the ContactListFragment’s ListView. AsyncTask method execute performs the task in a separate thread. Method execute’s argument in this case indicates that the task does not receive any arguments—this method can receive a variable number of arguments that are, in turn, passed as arguments to the task’s doInBackground method. Every time line 93 executes, it creates a new GetContactsTask object—this is required because each AsyncTask can be executed only once ...

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.