4.6 MainActivity Class

Class MainActivity (Sections 4.6.14.6.7) hosts the app’s MainActivityFragment when the app is running in portrait orientation, and hosts both the SettingsActivityFragment and MainActivityFragment when the app is running on a tablet in landscape orientation.

4.6.1 package Statement and import Statements

Figure 4.24 shows the MainActivity package statement and import statements. Lines 6–19 import the various Android and Java classes and interfaces that the app uses. We’ve highlighted the new import statements, and we discuss the corresponding classes and interfaces in Section 4.3 and as they’re encountered in Sections 4.6.24.6.7.

Fig. 4.24 MainActivity package statement and import statements

Get Android How to Program, 3/e 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.