Reputation: 77646
I have 2 activities Activity1 and Activity2.
I navigate from Activity1 to Activity2 (Call startActivity), and when I click back it starts a brand new Activity1.
Is there a way to keep Activity1 alive so that it keeps its state?
Upvotes: 0
Views: 91
Reputation: 1429
When you do a startActivity() from an activity, Android pauses the current activity and puts it in the background. For that moment, onPause() method of current activity is called.
In addition, if you want to save the current state, you can also override the onSavedInstanceState() method.
Check out some of these references as well as the Android Life Cycle.
http://developer.android.com/reference/android/app/Activity.html http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html
Upvotes: 1
Reputation: 1017
Ofcourse there is a way. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack").
http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html
Upvotes: 0