Reputation: 7304
I have four activities Activity1, Activity2, Activity3, and Activity4.
Activity1 calls Activity2.
Activity2 calls Activity3, then Activity2 is finished.
Activity3 calls Activity4, Activity3 is finished.
So now I have only Activity1 and Activity4.
Currently the user can see Activity4. Under certain condition, I like to go back to Activity1 but I still want to keep the existing status of Activity4 so that when I come back to Activity4, I still have all like before I switched to Activity1. My questions are
Activity4 is WebView and it has url links before switching back to Activity1. Thanks
Upvotes: 0
Views: 74
Reputation: 13761
You can achieve that by simply calling:
final Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
As you see, finish()
is not called, this is because your first Activity
will be started and the current will be put in background. The same goes on the first one if you want to recover the forth state without losing it.
Upvotes: 5