January 2014
Intermediate to advanced
736 pages
70h 43m
English
Class CannonGameFragment (Fig. 6.6) overrides four Fragment methods:
• onCreateView (lines 17–28)—As you learned in Section 5.3.3, this method is called after a Fragment’s onCreate method to build and return a View containing the Fragment’s GUI. Lines 22–23 inflate the GUI. Line 26 gets a reference to the CannonGameFragment’s CannonView so that we can call its methods.
• onActivityCreated (lines 31–38)—This method is called after the Fragment’s host Activity is created. Line 37 calls the Activity’s setVolumeControlStream method to allow the game’s audio volume to be controlled by the device’s volume keys.
• onPause (lines 41–46)—When the MainActivity is sent to the background (and thus, paused), the ...
Read now
Unlock full access