It isn't possible to do what you want using Intent flags.
The reason is due to the way that FLAG_ACTIVITY_REORDER_TO_FRONT
works. When you use this flag, Android looks for an instance of the desired activity in your activity stack, starting from the front of the stack and scanning until it gets to the root/back of the stack. As soon as it finds an instance of the specified activity, it brings that one to the front (ie: if there are multiple instances of the specified activity it will bring to the front the most recent instance).
In your case, the activity stack looks like:
A1, B, A2 (front of task)
When trying to reorder your activity A, Android finds the instance A2 first and reorders that to the front of the task. Of course, it was already at the front of the task so this doesn't really do anything.
Of course you've already called finish()
on this activity and you've tried (by using FLAG_ACTIVITY_PREVIOUS_IS_TOP
) to tell Android that it shouldn't consider the current activity while deciding what to do, but this is all ignored. Android sees A2 as the most recent instance of activity A and reorders it to the front. Then A2 is finished and activity B becomes the front of the task. The user sees "B" and the activity stack is:
A1, B (front of task)
You'll need to find another way to achieve the desired results (since this post is almost 2 years old I assume that you've already found another way).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…