Traverse Between Activities In Stack
Solution 1:
This is actually a very bad architecture for Android. If you create multiple instances on an Activity
, there is no way to specifically address them, for example: "Go back to the first instance of ActivityB
". Android isn't designed like this.
You should avoid creating multiple instances of an Activity
. It is beter to use the same instance and just create the "illusion" of multiple instances by swapping out the underlying data and maybe adding a state transition on the display so that it looks like you are starting another Activity
.
Another possible solution would be to use a lot of startActivityForResult()
and return information to the calling Axctivity
about what to do next.
For more details see (even though these questions are specifically about using FLAG_ACTIVITY_REORDER_TO_FRONT
, the problem is still basically the same):
Solution 2:
Use Flags with Intent.
official Docs: https://developer.android.com/guide/components/tasks-and-back-stack.html
pass the flag along with Intent
FLAG_ACTIVITY_CLEAR_TOP
also you can paas multiple FLags in a single Intent according to your need.
Hope this helps.
Post a Comment for "Traverse Between Activities In Stack"