O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Set ContactActivity as Default Activity with no Contacts in Database

The final task is to modify the onResume method of the ContactListActivity to check if there are any contacts in the database. If there are not, the app should open the ContactActivity. Refer to Listing 6.20 to make these changes.

Listing 6.20 Modify the onResume Method to Check for Contacts

if (contacts.size() > 0) {                                                        //1    adapter = new ContactAdapter(this, contacts);    setListAdapter(adapter);    ListView listView = getListView();    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {        @Override        public void onItemClick(AdapterView<?> parent, View itemClicked, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required