Search code examples
androidactivity-lifecycleandroid-recents

Recents Screen and Activity Lifecycle


What is the exact life-cycle path for an Android activity when it is shown to the user in the recents screen and when it renters into the user's view? I want to know if I can determine if the user left the app (onPause() and/or onStop()) is called and then returned back to it with the activity remaining in the foreground.


Solution

  • It depends. Is the activity still resident in memory or was it destroyed? In the first case, it would get onStart, then onResume. In the second, it would go through the entire normal lifecycle of any activity being launched (including onRestoreInstanceState to restore any saved values).