I am having trouble finding out how to maintain the state of my Android app in development.
Just to clarify, I am not talking about maintaining activity state (i.e. keeping track of textbox values, checkboxes, etc on a specific activity).
Let's say for example my application has two activities A
and B
. When I start my app, it takes me to activity A
, and pressing a button on it takes me to activity B
. At this point, I press the home button on my phone to return to the main Android UI and exiting my app . However, if I choose to run my app again, it should take me to activity B
, which is where I left off before pressing the home button, but instead it is taking me to activity A
.
Does anyone know how I can rectify this?
(I am using a Samsung Vibrant in case if you need to know)
"However, if I choose to run my app again, it should take me to activity B, which is where I left off before pressing the home button, but instead it is taking me to activity A."
Yes, it should. If it isn't, you have done something in your app to tell the platform to modify its behavior. (Look at ApiDemos as an example, it uses the standard behavior, which is what it sounds like you are describing as what you expect.)
Things to look out for: