I have a home activity A, from where I open activity B. In B there are some complex views with states with data fetched from the network. From B with the press of a button I go to activity C.
Now if I press back, I go to B with the states preserved.
Problem:
I want to have a button in C and when I press it I open B but in a fresh state i.e. like it was called for the first time but the back button functionality to not break. I also want to keep activity A on the stack as the flow was.
How can I do this?
Asked
Active
Viewed 207 times
0

Jim
- 3,845
- 3
- 22
- 47
-
With simple straightforward programming. But wait - what about pressing back from the "fresh B" ? Back to C, then back to "filled up B" ? – Shark Feb 10 '22 at 18:23
-
@Shark: I don't understand your suggestion. Is there a problem with my post? – Jim Feb 10 '22 at 18:34
1 Answers
0
To return from C to B but create a new instance of B, do this in C:
Intent intent = new Intent(this, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();

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