Understanding Activity Lifecycle and the Stack — Part 3

<p>In this tutorial, we will be discussing a small topic related to the activity lifecycle. This topic is a continuation of the previous tutorial, so let&rsquo;s dive in.</p> <p>In Android, the concept of activity and its lifecycle is based on a structure known as a stack. A stack follows the last in, first out (LIFO) principle. When you open an activity, it becomes visible on the screen and fills the stack as the first element. For example, when you open activity A, it becomes visible and fills the stack.</p> <p>When you click a button to open activity B, activity A goes into the onStop state and activity B becomes the second element in the stack. Activity A is not destroyed, it is still present in the stack. Similarly, when you click a button to migrate to activity C, activity C comes to the onResume state, activity B goes into the onStop state, and at the top of the stack, we have activity C.</p> <p><a href="https://blog.stackademic.com/understanding-activity-lifecycle-and-the-stack-part-3-2134949d53c1"><strong>Website</strong></a></p>
Tags: Stack Part