Android Programming The Big Nerd Ranch Guide, 3rd Edition

(Brent) #1

Chapter 5  Your Second Activity


110

Listing 5.18  QuizActivity declared as launcher activity


(AndroidManifest.xml)


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
... >


<application
... >












After the instance of QuizActivity is on screen, the user can press the CHEAT! button. When this
happens, an instance of CheatActivity is started – on top of the QuizActivity. These activities exist
in a stack (Figure 5.12).


Pressing the Back button in CheatActivity pops this instance off the stack, and the QuizActivity
resumes its position at the top, as shown in Figure 5.12.


Figure 5.12  GeoQuiz’s back stack


A call to Activity.finish() in CheatActivity would also pop the CheatActivity off the stack.

Free download pdf