skip to main |
skip to sidebar
android lifecycle example
onCrate()
- Called when: first method to be called.
- Single parameter Bundle, initially null.
- Bundle contains info when activity is restarted.
- Appropriate place to code for: any startup, layout setup & data binding.
onResume()
- Called when: Background activity comes on top of stack and becomes foreground activity.
- Appropriate place to code for: To retrieve any resources required by activity to run.
onPause()
- Called when: When any activity is pushed down the stack i.e. Activity migrates from foreground to background.
- Appropriate place to code for: Stop any audio, video, animation, deactivate resources such as database cursor, clean up & release any resource.
onDestory()
- Called when: When activity is being destroyed (Due to two reason : voluntarily or forcefully by platform.)
onSaveInstanceState() & onRestoreInstanceState()
- Saving & retrieving information state to bundle object.
0 comments:
Post a Comment