[Android] The Lifecycles of Activity and SurfaceView

0_12803210018q71-1

1. Opening the app
Activity callback order: onCreate()->onStart()->onResume()
SurfaceView callback order: surfaceCreated()->surfaceChanged()

2. Closing the app (pressing the BACK key)
Activity callback order: onPause()->onStop()->onDestory()
SurfaceView callback order: surfaceDestroyed()

3. Sending the app to the background (pressing the HOME key)
Activity callback order: onPause()->onStop()
SurfaceView callback order: surfaceDestroyed()

4. Bringing the app to the foreground
Activity callback order: onRestart()->onStart()->onResume()
SurfaceView callback order: surfaceChanged()->surfaceCreated()

5. Locking the screen (pressing the end-call key or locking the screen directly)
Activity callback order: onPause()
No SurfaceView methods are called.

6. Unlocking the screen
Activity callback order: onResume()
No SurfaceView methods are called.

Add a Comment

Your email address will not be published. Required fields are marked *