I am having four tabspec in tabhost TA1,TA2,TA3,TA4 in which i set current tab as TA2, I set four different activities for four tabspec A1, A2, A3 and A4 respectively, Activity A1 is set to TA1 and so on,then Activity A1 Open new activity B1, when i pressed back button from activity B1 the tab should be set to TA1 not to default TA2, How can i achieve above task in tab host, I tried to store current index of tab into shared preferences and onResume i read int value of current tab from shared preferences, but this way i was not able to achieve above task, Please let me know if anyone knows the best solution.
Hi Friends i resolved my issue by passing value through intent to main tab activity, here below is sample code,Set this code lines to child activity of tab that means if i relate to above question child activity is "B1",
Intent homeIntent = new Intent(SelectFetchee.this, Home.class);
homeIntent.putExtra("tabvalue", "2");
startActivity(homeIntent);
Then in main activity that have tabhost in which i collect the string
String crntTab = getIntent().getStringExtra("tabvalue");
if (crntTab == null) {
tabHost.setCurrentTab(2);
} else if (crntTab.toString().equals("4")) {
tabHost.setCurrentTab(4);
} else if (crntTab.toString().equals("2")) {
tabHost.setCurrentTab(2);
} else if (crntTab.toString().equals("3")) {
tabHost.setCurrentTab(3);
} else if (crntTab.toString().equals("0")) {
tabHost.setCurrentTab(0);
} else if (crntTab.toString().equals("1")) {
tabHost.setCurrentTab(1);
}