samedi 9 mai 2015

How to access a singleton Android Activity in a backstack multiple times

A1 is the main activity. It is a single instance activity meaning it should not be instantiated more than once since it is expensive to re-create it.

The scenario is:

  • A1 calls A2
  • A2 calls A3
  • A3 calls A1

Expected backstack is:

Top -> [A1|A3|A2|A1] <- bottom

I would like A1 stay on the top of this stack. Therefore, when I hit the back button, I expect to return to A3, then A2, and finally back to A1.

Currently A1 is defined as launchMode=singleinstance. Naturally, second call to A1 clears all other activities (A2 and A3) from the backstack.

Question is, how can I let a singleton activity exist in a backstack more than once for navigation purposes?

Note: Assuming that the backstack structure is internally composed of references to the activities, then somehow I should be able to create two different references to a singleton Activity.

Aucun commentaire:

Enregistrer un commentaire