I have a set of activities that I am navigating between, and because these activities are expensive to initialize, I would like to preserve the existing state if possible. The problem is that I might have the same activity open more than once, with a different state in each, and I didn't see a way that the standard Android flags could help me out with that situation.
Here's a visual example:
Imagine I have three activities:
A, B, C
Each of these activities can be open more than once, each one holding a different state. Not only are these activities expensive to initialize, but I'd also like to maintain the user's current state such as scroll position, selected items, etc...
Let's say that A(1) is an instance of activity A in state 1, and A(2) is an instance of activity A in state 2. A(1) and B(1) are unrelated.
I want to implement a circular navigation stack as follows:
... --> A(1) --> A(2) --> B(1) --> B(2) --> B(3) --> A(3) --> C(1) --> A(1) --> ...
Since the activities are expensive, I'd really like to just reuse the existing instances. However, I might need to keep around 2 or 3 instances of the same activity as you can see above.
Thanks!