0

I have a user case like this:

Activity A -> B -> C ->D.

In the Activity D, I want to get back to the Activity A. I tried with Intent and it is okay, however, instead of reusing the existing one, it created a new one. Anyone please let me know how to cope it?

Thank a lot!

Adam Arold
  • 29,285
  • 22
  • 112
  • 207
moc
  • 76
  • 8

2 Answers2

1

There is a fine topic on developer.android regarding exactly this question, check it out: avoiding memory leaks

Adam Arold
  • 29,285
  • 22
  • 112
  • 207
0

You need to set the flags on the intent when you start A again

Intent i = new Intent(this, ActivityA.class); 
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(i);

see public Intent setFlags (int flags)

for reference

NickT
  • 23,844
  • 11
  • 78
  • 121