I implemented a swipe tab in a fragment. This fragment has two tabs, tab1 and tab2. when i click on tab2, a new activity will load. however, when i click on the back button, it directs to the fragment but not the tab i selected previously. it should display tab2 not tab1 contents. how can i do that?
Asked
Active
Viewed 433 times
-2
-
have a look at [this](http://stackoverflow.com/questions/32345827/fragment-rotation/32346072#32346072) – Kaveesh Kanwal Sep 11 '15 at 04:29
1 Answers
0
You need to remember on which tab you were onStop()
, for example using SharedPreferences
, or startActivityWithResult
when you start your activity. Then when you come back, check onStart()
and retrieve from the SharedPreferenes
, or 'onResult' and move the tab to the good tab.

xiaomi
- 6,553
- 3
- 29
- 34