Question: I am developing an app which has a `FragmentActivity` in which I have an `ActionBar` with 3 tabs at the top. In each tab I am loading a particular Fragment.

The thing I want to know is when my application is in foreground and suppose user was seeing the third tab and then he presses the `home` button, the application goes in background. When after some time when he taps on the application icon on the homescreen the application will come in foreground and at point of time I want the user to see a particular tab other than the third tab. (which is default behavior).

How can I achieve this ?

I tried using 
`actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(SectionIterator)).setTabListener(this), true);`

in `onCreate()` method but this works only when app is started for the first time and not when app is brought to foreground from the background.

Any insight is appreciated.

Answer: 
The way i accomplished this is as suggested by @Omer using the `onResume()` method.

Inside the `onResume()` method I have written the following code

```
ViewPager pager = (ViewPager)findViewById(R.id.pager);

int DefaultTabToBeSelected = vGetValueForDefaultTab();

pager.setCurrentItem(DefaultTabToBeSelected);       

```
Use the onResume() method. this method gets called whenever the user comes back into your application after leaving it (but not killing it entirly)

![enter image description here](https://i.stack.imgur.com/leabD.png)