I have 2 tabs , for example Tab1 & Tab2 which is displayed on the screen. Let the tabs be displayed on the PORTRAIT orientation.
Tab1 displays Activity1 & Ta
That's not the best way. You should use onRetainNonConfigurationInstance() and getLastNonConfigurationInstance() to retain the state between config changes. Those methods are specifically for saving state during config changes.
public Object onRetainNonConfigurationInstance() {
return mTabHost.getCurrentTab();
}
public void onCreate() {
...
Integer lastTab = (Integer) getLastNonConfigurationInstance();
if(lastTab != null) {
mTabHost.setCurrentTab(lastTab);
}
...
}