문제

Supposing I have the following activities:

  • Activity A
  • Activity B
  • Activity C
  • Activity D

A calls B, B calls C and C calls D, so my stack is, from top to bottom, D-C-B-A.

Now I want call from D the activity B in order to obtain the following stack:

B-A

Where B is not the previous instance that was in the initial stack configuration (D-C-B-A) but is a new instance.

What FLAG_ACTIVITY_ I have to use?

I have tried using this :

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);

But this give me the old instance of Activity B, on top of the stack.

도움이 되었습니까?

해결책

Take out the flag Intent.FLAG_ACTIVITY_SINGLE_TOP. From the docs:

The currently running instance of activity B in the above example will either receive the new intent you are starting here in its onNewIntent() method, or be itself finished and restarted with the new intent. If it has declared its launch mode to be "multiple" (the default) and you have not set FLAG_ACTIVITY_SINGLE_TOP in the same intent, then it will be finished and re-created; for all other launch modes or if FLAG_ACTIVITY_SINGLE_TOP is set then this Intent will be delivered to the current instance's onNewIntent().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top