6.8.11. Methods stopGame and releaseResources
Class CannonGameFragment
’s onPause
and onDestroy
methods (Section 6.7) call class CannonView
’s stopGame
and releaseResources
methods (Fig. 6.17), respectively. Method stopGame
(lines 464–468) is called from the main Activity
to stop the game when the Activity
’s onPause
method is called—for simplicity, we don’t store the game’s state in this example. Method releaseResources
(lines 471–475) calls the SoundPool
’s release method to release the resources associated with the SoundPool
.
463 // stops the game; called by CannonGameFragment's onPause method464 public void stopGame()465 {466 if (cannonThread != null)467 cannonThread.setRunning( ...
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.