I have two activities and I can change from one activity to other by swiping (i am overriding overridePendingTransition()
in base activity which two activities are being inherited) and I am using intents to switch between activities. But when I come from second activity to first, I don't want to create a new intent rather I use previous state. (I have lots of data on UI of both activities, I prefer not to redraw everything and sharing Bundle
between activities). When I am going to second activity I did not destroy the first one. How can I restore that state, basically UI
should not change?
Asked
Active
Viewed 251 times
1

Avog
- 139
- 17
-
use `finish();` in second activity instead of using Intent to call first activity. – W I Z A R D Apr 15 '14 at 08:51
-
What if I want to restore second activity? – Avog Apr 15 '14 at 09:06
-
[link](http://stackoverflow.com/questions/6791493/how-to-make-an-activity-stop-rather-then-be-destroyed-from-the-back-key) – W I Z A R D Apr 15 '14 at 10:21
1 Answers
0
You can switch between 2 activities like this:
In activity A, when you want to switch to activity B do:
Intent intent = new Intent(this, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
In activity B, when you want to switch to activity A do:
Intent intent = new Intent(this, A.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);

David Wasser
- 93,459
- 16
- 209
- 274