Issue
I'm very confused about FLAG_ACTIVITY_CLEAR_TASK
in combination to FLAG_ACTIVITY_NEW_TASK
. Isn't FLAG_ACTIVITY_CLEAR_TASK
supposed to clear TARGET task but not caller task?
Let's assume I have this navigation
A -> B -> C
Where B
calls C
with FLAG_ACTIVITY_NEW_TASK
and FLAG_ACTIVITY_CLEAR_TASK
. How is that supposed to clear A
and B
from stack? I know that's happening because I tested it (If I click back on C
, I leave the app), but I don't fully understand why... A
and B
are part of a different task that is not the task C
will be created on.
FLAG_ACTIVITY_CLEAR_TASK
If set in an Intent passed to Context.startActivity(), this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started.
Maybe text in bold above means that caller and target task are cleared. It's unclear to me what associated
would be.
Solution
FLAG_ACTIVITY_CLEAR_TASK
will clear all existing task by starting the new activity in your case it's C
.
I think you need FLAG_ACTIVITY_CLEAR_TOP
and this will clear only the top activity from stack in your case B
.
You might be interesting with other flags, check here.
Answered By - user6490462
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.