1

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?

Avog
  • 139
  • 17

1 Answers1

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