0

Suppose I have Two tabs Tab1 and Tab2
and three activities in Tab1 A,B,C
now user navigated to A->B->C
now if I am in Activity C and I click on Tab1 how will I move back to Activity A?

I want it to function same as iPhone i.e when user clicks on tab he is back to Home screen of that Tab.

Edit: Am using ActivityGroup

Just Variable
  • 892
  • 10
  • 19

2 Answers2

1

there are a number of question like http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP

This one and this

might be this helps you

Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Removes other Activities from stack
startActivity(intent);

if you want to load the old state you need to save it first.

Community
  • 1
  • 1
Ishtiaq
  • 1,206
  • 9
  • 18
  • Thanks, but where I will put this code if I am in same tab ? I checked with onTabChangeListener but its not triggered when you are in same tab ? – Just Variable Oct 24 '12 at 11:19
  • try to call the previous activity in the same way as you call the next within the tab in activity group – Ishtiaq Oct 24 '12 at 11:50
1

You can't have 3 activities in one tab. Instead you should use a fragment in your tab and add or remove fragments in the stack.

I suggest you to use 3 fragments in a container and call replace on a FragmentTransaction with your first fragment when you when to come back to initial state.

Damien Praca
  • 3,126
  • 21
  • 14