0
0
Android Kotlinmobile~10 mins

Activity lifecycle methods (onCreate, onStart, onResume, onPause, onStop, onDestroy) in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to override the method that is called when the activity is first created.

Android Kotlin
override fun [1](savedInstanceState: Bundle?) {
    super.[1](savedInstanceState)
    setContentView(R.layout.activity_main)
}
Drag options to blanks, or click blank then click option'
AonResume
BonStart
ConCreate
DonPause
Attempts:
3 left
💡 Hint
Common Mistakes
Using onStart instead of onCreate
Forgetting to call super method
2fill in blank
medium

Complete the code to override the method called when the activity becomes visible to the user.

Android Kotlin
override fun [1]() {
    super.[1]()
    // Activity is now visible
}
Drag options to blanks, or click blank then click option'
AonResume
BonStart
ConPause
DonStop
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing onStart with onResume
Not calling the super method
3fill in blank
hard

Fix the error in overriding the method that is called when the activity is about to go into the background.

Android Kotlin
override fun [1]() {
    super.[1]()
    // Pause ongoing actions
}
Drag options to blanks, or click blank then click option'
AonDestroy
BonStop
ConStart
DonPause
Attempts:
3 left
💡 Hint
Common Mistakes
Using onStop instead of onPause
Forgetting to call super method
4fill in blank
hard

Fill both blanks to override methods that handle when the activity is no longer visible and when it is destroyed.

Android Kotlin
override fun [1]() {
    super.[1]()
    // Activity is no longer visible
}

override fun [2]() {
    super.[2]()
    // Cleanup before activity is destroyed
}
Drag options to blanks, or click blank then click option'
AonStop
BonPause
ConDestroy
DonStart
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up onPause and onStop
Not calling super methods
5fill in blank
hard

Fill all three blanks to override methods that manage the activity lifecycle from visible to interactive to paused.

Android Kotlin
override fun [1]() {
    super.[1]()
    // Activity is visible
}

override fun [2]() {
    super.[2]()
    // Activity is interactive
}

override fun [3]() {
    super.[3]()
    // Activity is partially obscured
}
Drag options to blanks, or click blank then click option'
AonStart
BonResume
ConPause
DonStop
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing onPause with onStop
Incorrect order of lifecycle methods