6.8.12. Implementing the SurfaceHolder.Callback Methods
Figure 6.18 implements the surfaceChanged, surfaceCreated and surfaceDestroyed methods of interface SurfaceHolder.Callback
. Method surfaceChanged
has an empty body in this app because the app is always displayed in portrait orientation. This method is called when the SurfaceView
’s size or orientation changes, and would typically be used to redisplay graphics based on those changes. Method surfaceCreated
(lines 485–494) is called when the SurfaceView
is created—e.g., when the app first loads or when it resumes from the background. We use surfaceCreated
to create and start the CannonThread
to begin the game loop. Method surfaceDestroyed
(lines 497–515) is called when the SurfaceView
is destroyed—e.g., ...
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.