-1

Very simple question I'm starting an Activity and I want to be sure there will be exaclty one of that at the stack...

imagine the stacks:

A B C <- top
C <- top

in Activity C i'm starting A, but if A already exists I want it to be brought to the top instead of create a new one...

Which flags shall i pass to the intent?

Rafael Lima
  • 3,079
  • 3
  • 41
  • 105
  • 1
    Possible duplicate of [Intent - if activity is running, bring it to front, else start a new one (from notification)](https://stackoverflow.com/questions/19039189/intent-if-activity-is-running-bring-it-to-front-else-start-a-new-one-from-n) – sebasira Sep 12 '18 at 16:40

2 Answers2

0

Add this to your Activity A in AndroidManifest.xml

android:launchMode="singleTask"
Yasiru Nayanajith
  • 1,647
  • 17
  • 20
0

Add FLAG_ACTIVITY_CLEAR_TASK and FLAG_ACTIVITY_CLEAR_TOP.

enter image description here

Mirza Adil
  • 352
  • 5
  • 9