The Activity Stack, 45/100 Days of Code
When planning your application’s Activities, find ways to minimize the size of the Activity Stack.
The Activity Stack is used to keep track of every open Activity in your application. The more open Activities, the more memory used by your app.
Let’s go over the meaning of an open Activity. You can also find a video of my explanation at the bottom of this at the bottom of the page.
Let’s take the ClickingActivities project we’ve been working on for example. This app allows users to open each Activity by clicking a button. The first Activity lets you start the second, the second lets you start the third, and the third opens the first Activity.
As users continue to open Activities, the Activity Stack will grow and consume memory which can slow down a device and affect other resources as well.
To avoid this, we can add the second and third Activities as children of the first Activity. This way, users can access each Activity without adding multiple versions of each Activity to the Activity Stack. For more on this topic, click here
Next week I will show you how to edit our app to do just this.
Join the mailing list to see updates like this every week!
Coding Fanatic