I am building an app that connects to a remote server and then lets you do actions on that server, display data, etc.
There is a "Connect" activity that lets you type the IP address of the server and has a Connect button. Once connected, there are activities B, C, D that are independent and act on different aspects of the server.
If you click the "menu" button, it allows you navigate to any of the activities. If you are disconnected, you can only navigate to the "Connect" activity... the other menu items are disabled.
Here are use cases for how I want the "back" button and task "back stack" behavior to work:
- When the app first starts, open the Connect activity
- If the app crashes (God forbid), start the Connect activity. Do not try to return to B, C, or D!
- If viewing B, C, or D and the connection is lost, "back" button takes you directly to the Connect activity.
- If your stack looks like Connect->B->C->D, then you navigate to the Connect screen and disconnect, your stack changes to Connect (only). You cannot hit "back" and go back to B, C, or D
- If you leave the app (click "Home" button) and come back by clicking the app icon, it should return to the top of the stack (assuming the connection was not lost in the meantime).
- If you are connected, "back" takes you to the previous Activity. Ex. assume Connect->B->C->D->Connect->C->B. One "back" takes you to "C", another "back" to Connect, another "back" to D (i.e. a normal stack).
Any recommendations on how to do this? Especially item 2 above (giving me a big headache... and yes, crashing should not happen)
I have read the Tasks and Back Stack dev guide, but can't decide how all the launch modes and affinities could be applied to this situation.