Bird
Raised Fist0
Android Kotlinmobile~5 mins

Activity lifecycle methods (onCreate, onStart, onResume, onPause, onStop, onDestroy) in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is the purpose of the onCreate method in an Android Activity?
The onCreate method is called when the activity is first created. It is used to initialize the activity, set up the user interface, and prepare any data needed for the activity.
Click to reveal answer
beginner
Which lifecycle method is called when the activity becomes visible to the user but is not yet interactive?
The onStart method is called when the activity becomes visible but is not yet in the foreground for user interaction.
Click to reveal answer
intermediate
Explain the difference between onPause and onStop methods.
onPause is called when the activity is partially obscured but still visible (like a dialog on top). onStop is called when the activity is no longer visible to the user.
Click to reveal answer
intermediate
When is onDestroy called in the activity lifecycle?
onDestroy is called before the activity is destroyed, either because the activity is finishing or the system is temporarily destroying it to save space.
Click to reveal answer
beginner
What lifecycle method is called when the activity starts interacting with the user?
onResume is called when the activity is in the foreground and ready for the user to interact with.
Click to reveal answer
Which method is called first when an activity is launched?
AonPause
BonStart
ConResume
DonCreate
What happens in the onPause method?
AActivity is no longer visible
BActivity is fully visible and interactive
CActivity is partially obscured but still visible
DActivity is destroyed
Which lifecycle method should you use to release resources when the activity is no longer visible?
AonStop
BonStart
ConResume
DonCreate
If the user presses the back button, which lifecycle method is called before the activity is destroyed?
AonDestroy
BonStop
ConPause
DonStart
Which method is called when the activity returns to the foreground after being paused?
AonStart
BonResume
ConCreate
DonStop
Describe the sequence of lifecycle methods called from launching an activity to it being fully interactive.
Think about the steps from creation to user interaction.
You got /4 concepts.
    Explain what happens in the lifecycle when the user switches to another app and then returns.
    Consider what happens when the activity is hidden and then shown again.
    You got /5 concepts.

      Practice

      (1/5)
      1. Which lifecycle method is called first when an Android activity is launched?
      onCreate(), onStart(), onResume(), or onPause()?
      easy
      A. onStart()
      B. onResume()
      C. onCreate()
      D. onPause()

      Solution

      1. Step 1: Understand activity launch sequence

        When an activity starts, onCreate() is the first method called to set up the UI and initialize components.
      2. Step 2: Confirm order of lifecycle methods

        After onCreate(), onStart() and onResume() follow, but they are not first.
      3. Final Answer:

        onCreate() -> Option C
      4. Quick Check:

        First lifecycle method = onCreate() [OK]
      Hint: Remember: onCreate() is always first when activity starts [OK]
      Common Mistakes:
      • Confusing onStart() as the first method
      • Thinking onResume() is called before onCreate()
      • Assuming onPause() is called on launch
      2. Which of the following is the correct Kotlin syntax to override the onPause() method in an Android activity?
      easy
      A. override fun onPause() { pause.super() }
      B. fun onPause() { super.onPause() }
      C. override onPause() { super.onPause() }
      D. override fun onPause() { super.onPause() }

      Solution

      1. Step 1: Check Kotlin override syntax

        In Kotlin, to override a method, use override fun methodName() and call super.methodName() inside.
      2. Step 2: Validate each option

        override fun onPause() { super.onPause() } correctly uses override fun onPause() and calls super.onPause(). Others miss override keyword, have wrong syntax, or wrong super call.
      3. Final Answer:

        override fun onPause() { super.onPause() } -> Option D
      4. Quick Check:

        Correct override syntax = override fun onPause() { super.onPause() } [OK]
      Hint: Always use 'override fun method()' and call 'super.method()' inside [OK]
      Common Mistakes:
      • Omitting the override keyword
      • Calling super incorrectly
      • Wrong function declaration syntax
      3. Consider this Kotlin code snippet inside an activity:
      override fun onPause() {
          super.onPause()
          println("Paused")
      }
      override fun onStop() {
          super.onStop()
          println("Stopped")
      }

      What will be printed if the user presses the home button while the activity is visible?
      medium
      A. Stopped Paused
      B. Paused Stopped
      C. Paused
      D. Stopped

      Solution

      1. Step 1: Understand lifecycle on home press

        Pressing home triggers onPause() first, then onStop() as activity goes to background.
      2. Step 2: Check print order

        Since onPause() runs before onStop(), "Paused" prints first, then "Stopped".
      3. Final Answer:

        Paused Stopped -> Option B
      4. Quick Check:

        onPause() then onStop() prints = Paused, Stopped [OK]
      Hint: onPause() always runs before onStop() when leaving activity [OK]
      Common Mistakes:
      • Assuming onStop() runs before onPause()
      • Thinking only one method runs on home press
      • Confusing print order
      4. This code snippet is intended to save data when the activity is paused:
      override fun onPause() {
          saveData()
      }

      What is the main problem with this code?
      medium
      A. Missing call to super.onPause()
      B. saveData() should be called in onStop() instead
      C. onPause() cannot be overridden
      D. saveData() must be asynchronous

      Solution

      1. Step 1: Check lifecycle method override rules

        When overriding lifecycle methods, always call super.method() to keep system stable.
      2. Step 2: Identify missing super call

        The code lacks super.onPause(), which can cause unexpected behavior.
      3. Final Answer:

        Missing call to super.onPause() -> Option A
      4. Quick Check:

        Always call super in lifecycle overrides [OK]
      Hint: Never forget super.onPause() when overriding onPause() [OK]
      Common Mistakes:
      • Forgetting to call super method
      • Thinking onPause() can't be overridden
      • Assuming saveData() timing is wrong
      5. You want to release a camera resource when the activity is no longer visible to save battery. Which lifecycle method is the best place to release the camera?
      A) onDestroy()
      B) onStop()
      C) onPause()
      D) onResume()
      hard
      A. onPause()
      B. onStop()
      C. onDestroy()
      D. onResume()

      Solution

      1. Step 1: Understand visibility and resource management

        When activity is partially or fully hidden, onPause() is called first, signaling to release resources like camera to save battery.
      2. Step 2: Compare lifecycle methods for releasing resources

        onStop() is later, but releasing in onPause() ensures resources are freed as soon as activity is not in foreground. onDestroy() may never be called if system kills process. onResume() is for acquiring resources.
      3. Final Answer:

        onPause() -> Option A
      4. Quick Check:

        Release resources in onPause() to save battery [OK]
      Hint: Release heavy resources in onPause(), reacquire in onResume() [OK]
      Common Mistakes:
      • Waiting until onStop() or onDestroy() to release resources
      • Releasing resources in onResume() by mistake
      • Not releasing resources early enough
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard