How to tag Activity

android

Solution

The best and the easiest solution (so far) will be use Fragments and FragmentManager. Then tag each Fragment and use FragmentManager. Using only Activity can be very difficult to have almost the same result.

Problem

I'm using this code to jump back in activity stack (mainly to move to home Activity): ``` Intent goTo = new Intent(this, HomeActivity.class); goTo.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(goTo); ``` So I create new Intent and set "target" to HomeActivity which is in Activity stack so whole stack will be cleared from top to this HomeActivity. Now I need slightly different use case. I have for example five Activities A-B-C-D-E (A started B etc.) on the stack. Now I need to jump from E to C or B depending of what user choose. The problem is that Activities A, B, C, D, E have same class. So I can't use example above because I don't know how to target that Activity. So the question is if there is any way how to "tag activity" or manipulate with stack. Thanks!

Original source