Easy way to achieve this: call finish() in your onPause method of the Activity.
public void onPause() {
super.onPause();
finish();
}
But you shouldnt really do this. Respect the Activity Lifecycle and move the things you need to do whenever the User switches to this Tab from onCreate() to onResume().
To clear things up for you:
-onCreate() gets called the first Time you switch to the Tab - or if it is killed by the system or by calling finish()
-onResume() gets called everytime you switch to the Tab
-onPause() gets called when you switch away from a Tab
Best thing to do:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setup your contentview etc
}
public void onResume() {
super.onResume();
//get your data
}