Search code examples
androidandroid-intentandroid-activity

How to bring an activity to foreground (top of stack)?


In Android, I defined an activity ExampleActivity.

When my application was launched, an instance of this A-Activity was created, say it is A. When user clicked a button in A, another instance of B-Activity, B was created. Now the task stack is B-A, with B at the top. Then, user clicked a button on B, another instance of C-Activity, and C was created. Now the task stack is C-B-A, with C at the top.

Now, when user click a button on C, I want the application to bring A to the foreground, i.e. make A to be at the top of task stack, A-C-B.

How can I write the code to make it happen?


Solution

  • You can try this FLAG_ACTIVITY_REORDER_TO_FRONT (the document describes exactly what you want to)