There is no standard way to do that, but then again, anything is possible with some logic! I had a similar problem in my earlier app. I solved it by maintaining a stack of last opened tabs, and then overriding the back button pressed to remove the tabs from the stack. Some sample code is given below.
Initialize the variables as follows
tabIdStack = new Stack<Integer>();
openedTab = 0;
and then override the onTabChanged()
@Override
public void onTabChanged(String tabId) {
if (!backButtonPressed) {
if (tabIdStack != null) {
if (tabIdStack.size() == noOfTabs)
tabIdStack.remove(0);
tabIdStack.push(openedTab);
openedTab = tabHost.getCurrentTab();
}
}
backButtonPressed = false;
and then you should also override the onBackPressed()
@Override
public void onBackPressed()
{
backButtonPressed = true;
if (tabIdStack.size() == 0)
this.finish();
else {
tabHost.setCurrentTab(tabIdStack.get(tabIdStack.size() - 1));
tabIdStack.remove(tabIdStack.size() - 1);
}
}