5.5. MainActivity Class

Class MainActivity (Figs. 5.18Fig. 5.23) hosts the app’s QuizFragment when the app is running in portrait orientation, and hosts both the SettingsFragment and QuizFragment when the app is running on a tablet in landscape orientation.

 1   // MainActivity.java 2   // Hosts the QuizFragment on a phone and both the 3   // QuizFragment and SettingsFragment on a tablet 4   package com.deitel.flagquiz; 5  6   import java.util.Set; 7  8   import android.app.Activity; 9   import android.content.Intent;10   import android.content.SharedPreferences;11   import android.content.SharedPreferences.OnSharedPreferenceChangeListener;12   import android.content.pm.ActivityInfo;                                    ...

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.