Reputation: 53
I have two activities, A - B on back stack, B on top
I knew I could use FLAG_ACTIVITY_REORDER_TO_FRONT to bring A on top, so that the stack becomes: B - A, A on top
But when there is only one activity, B on the stack: B(no A exists on the stack)
and I found FLAG_ACTIVITY_REORDER_TO_FRONT will create a new A and so that stack becomes: B - A
how do I have A on top ONLY IF A EXISTED on stack??
and
I wonder if there is any way I could check if A exists on back stack??
Upvotes: 0
Views: 332
Reputation: 2335
One trick you could do is to keep a static boolean variable in activity A
. Keep it false by default, make it true
in onCreate
of A
and false
in onDestroy
of A
In activity B
check if that value is true
then launch it otherwise don't.
Upvotes: 2