3

I have an application with a TabActivity containing ActivityGroup. Each tabs works fine, but for one specific tab I want to go back to the first child activity when there's a click on it (whenever we are in a child activity of this tab or inside another tab).

I tried to start the activity that I want on the onResume of my ActivityGroup, it works when I'm on another tab, but not when I'm on this tab, with a child activity.

Do I have to use another intent flag than FLAG_ACTIVITY_CLEAR_TOP for this tab ? Does anyone have a clue ?

Thanks.

magiccyril
  • 657
  • 1
  • 6
  • 14

1 Answers1

1

Usualy with ActivityGroup you have some kind of history.

Let's say your history is:

ArrayList<View> history;

Of course history needs to be initialized and have some Views in it which can be retrieved with:

getLocalActivityManager().startActivity(clazz.getName(), new Intent(this, clazz)).getDecorView();

where clazz is the class of your child Activity. So on click in current ActivityGroup define a method like:

public void backToFirst() {
    int size = history.size();
    while (size > 1) {
        history.remove(size - 1);
        size = history.size();
    }
    setContentView(history.get(0));
}

Hope I understood you correctly and this is the answer you are looking for.

Kostas
  • 2,434
  • 3
  • 19
  • 18
  • Thank you. I hadn't answerd, but I had done that : `code` public void resetChildActivities() { LocalActivityManager manager = getLocalActivityManager(); int index = mIdList.size() - 1; for (int i = index; i > 0; i--) { manager.destroyActivity(mIdList.get(i), true); mIdList.remove(i); } } `code` but your solution seams nicer. Thanks. – magiccyril May 26 '11 at 06:52
  • Hi everyone . iam new to android development .my requirement is i am facing one issue and unable to resolve it can anyone have a l ook onto it and help me in resolving the issue this is the l ink where i posted my code with logcats as well http://stackoverflow.com/questions/15223444/current-acivity-should-replaced-with-previous-activity-back – KAREEM MAHAMMED Mar 05 '13 at 12:16