January 2014
Intermediate to advanced
736 pages
70h 43m
English
When the user touches the Save Contact Button, the saveContactButtonClicked listener (Fig. 8.39) executes. To save a contact, the user must enter at least the contact’s name. Method onClick ensures that the length of the name is greater than 0 characters (line 107) and, if so, creates and executes an AsyncTask (to perform the save operation). Method doInBackground (lines 113–118) calls saveContact (Fig. 8.40) to save the contact into the database. Method onPostExecute (lines 120–131) programmatically hides the keyboard (lines 124–128), then notifies MainActivity that a contact was saved (line 130). If the nameEditText is empty, lines 139–153 display a DialogFragment telling the user that a ...
Read now
Unlock full access