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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.