0

I am making my first android application, and it requires switching between activities very frequently. I know I can call finish() to end the current Activity, but I was wondering if there was a way to not call finish() or startActivity(), but to somehow return to the old instance of that Activity? Not using the back button either.

If anyone has any ideas please let me know. Thanks

JuiCe
  • 4,132
  • 16
  • 68
  • 119

2 Answers2

4

can use FLAG_ACTIVITY_CLEAR_TOP it will clear all the activity till previous reference of this OLD_ACTIVITY.

use the flag Intent.FLAG_ACTIVITY_CLEAR_TOP with your intent. For more detail -

Intent i =new Intent(current_ACTIVITY.this, OLD_ACTIVITY.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);

there are more Flag like NO_History and more...........

Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36
1

From what I understand I would suggest that you use startActivityForResult() to launch a new activity and then on finish of the new activity you will get back to the old instance of the previous activity.

Arun George
  • 18,352
  • 4
  • 28
  • 28