Create your account

Already have an account? Login here

Create account

35. Example of an Activity Lifecycle

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to become a pro member, or login to your account to view this lesson.

Alright, join now. Or login to your account if you're already a pro member.

This video demonstrates how the Activity lifecycle methods are called by the Android system. When the app starts, onCreate, onStart, onResume are called which together constitute the Activity creation cycle. onCreate is called once per Activity creation and you can initialise Views and objects inside this method. When you move away from the Activity onPause and onStop are called. If you press back or rotate the screen the Activity is first destroyed which involves calling onPause, onStop, onDestroy and the Activity is created once again with the creation cycle. The onSaveInstanceState is called when the values of the relevant objects inside the activity is saved prior to destroying it. The onRestoreInstanceState is called giving the developer a chance to reload values into those objects whose state was saved in the onSaveInstanceState after the Activity was built from scratch.

Course Cirriculum