How can I close a tab
when I am leaving that tab.
or
How can I start an activity
when I am clicking a tab
each time.
How can I close a tab
when I am leaving that tab.
or
How can I start an activity
when I am clicking a tab
each time.
You need to set tab change listener
getTabHost().setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
int i = getTabHost().getCurrentTab();
Log.i(" ANN CLICK TAB NUMBER", + i);
if (i == 0) {
Log.i("Inside onClick tab 0", "onClick tab");
}
else if (i ==1) {
Log.i("Inside onClick tab 1", "onClick tab");
}
}
});
Depend on your activity stack if your current exactly on top of the parent activity you can just finish current actvity and it will go to previous activity. If you want to clear all activity stack and start over new activity try
Intent intent1 = new Intent(context, activity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent1);