Search code examples
androidandroid-activityactivity-stack

Proper way to add Activity under the top Activity


So I have a main activity, a disclaimer activity, and an update activity. The latter two are both added from the main activity. The update activity gets kicked off after it pulls down some data to see if it needs to update. So essentially what happens is I get this stack.

On Launch:

  1. Main -> Disclaimer -> Update (If they have not accepted the Disclaimer yet, I don't want the update on top)

  2. Main -> Update (If they already accepted the disclaimer, this works fine)

When I decide to add the Update View, I would like to check if the Disclaimer currently being displayed, and if so, add the Update View beneath it. Resulting in a stack like this for case 1 from above:

Main -> Update -> Disclaimer

What do you think is the best way to do this? I could just keep some booleans to keep track of if its shown, and then pop and push the disclaimer, but that seems messy.


Solution

  • You can keep a SharedPreference that says whether the Disclaimer has been shown and check that before launching. The use that to determine the flow.