MainActivity Overridden onCreate Method
Method onCreate
(Fig. 8.15) inflates MainActivity
’s GUI and, if the app is running on a phone-sized device, displays a ContactListFragment
. As you’ll see in Section 8.6, you can configure a Fragment
to be retained across configuration changes, such as when the user rotates the device. If the Activity
is being restored after being shut down or recreated from a configuration change, savedInstanceState
will not be null
. In this case, we simply return (line 28) because the ContactListFragment
already exists—on a phone, it would have been retained and on a tablet, it’s part of the MainActivity
’s layout that was inflated in line 24.
19 // display ContactListFragment when MainActivity ...
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.