Hi i currently have an Activity that hosts a tab view, and each tab is an Activity. The current problem i have is, on one of the activities(tab) i have some stuff i need to save on rotation, but it seems these methods dont get called when i change rotation, only on the activity that holds the tab view and launches each activity as a tab.
Here’s the activity’s onCreate method that holds the tabs:
LocalActivityManager mlam = new LocalActivityManager(this, false);
tabs=(TabHost)findViewById(android.R.id.tabhost);
mlam.dispatchCreate(savedInstanceState);
tabs.setup(mlam);
TabHost.TabSpec spec;
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, MyProcessList.class);
spec = tabs.newTabSpec("artists").setIndicator((buildTabIndicator("Home")))
.setContent(intent);
tabs.addTab(spec);
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, MyProcessList.class);
spec = tabs.newTabSpec("artists2").setIndicator((buildTabIndicator("Menu")))
.setContent(intent);
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, MyProcessList.class);
tabs.addTab(spec);
spec = tabs.newTabSpec("artists2").setIndicator((buildTabIndicator("Options")))
.setContent(intent);
tabs.addTab(spec);
tabs.setCurrentTab(0);`
The onSaveInstanceState/onRestoreInstanceState methods in the same class:
@Override
public void onSaveInstanceState(Bundle bundle) {
bundle.putString(BOB,"ola");
}
@Override
public void onRestoreInstanceState(Bundle bundle) {
String hi=bundle.getString(BOB);
System.out.println(hi);
}
But the activity as a tab(MyProcessList) own onSaveInstanceState/onRestoreInstanceState methods dont seem to get called…is there a way around this?
regards,
Here’s the warning i get when using the methods in the MainMenu activity:
05-11 12:15:16.017: W/Bundle(32053): Key BOB expected Bundle but value was a java.lang.String. The default value <null> was returned.
05-11 12:15:16.033: W/Bundle(32053): Attempt to cast generated internal exception:
05-11 12:15:16.033: W/Bundle(32053): java.lang.ClassCastException: java.lang.String cannot be cast to android.os.Bundle
05-11 12:15:16.033: W/Bundle(32053): at android.os.Bundle.getBundle(Bundle.java:1142)
05-11 12:15:16.033: W/Bundle(32053): at android.app.LocalActivityManager.dispatchCreate(LocalActivityManager.java:455)
05-11 12:15:16.033: W/Bundle(32053): at sinfic.mobile.ipdms.MainMenu.initActivity(MainMenu.java:66)
05-11 12:15:16.033: W/Bundle(32053): at sinfic.mobile.ipdms.core.IpdmsCoreActivity.onCreate(IpdmsCoreActivity.java:38)
05-11 12:15:16.033: W/Bundle(32053): at android.app.Activity.performCreate(Activity.java:4465)
05-11 12:15:16.033: W/Bundle(32053): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-11 12:15:16.033: W/Bundle(32053): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-11 12:15:16.033: W/Bundle(32053): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-11 12:15:16.033: W/Bundle(32053): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3351)
05-11 12:15:16.033: W/Bundle(32053): at android.app.ActivityThread.access$700(ActivityThread.java:123)
05-11 12:15:16.033: W/Bundle(32053): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
05-11 12:15:16.033: W/Bundle(32053): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 12:15:16.033: W/Bundle(32053): at android.os.Looper.loop(Looper.java:137)
05-11 12:15:16.033: W/Bundle(32053): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-11 12:15:16.033: W/Bundle(32053): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 12:15:16.033: W/Bundle(32053): at java.lang.reflect.Method.invoke(Method.java:511)
05-11 12:15:16.033: W/Bundle(32053): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-11 12:15:16.033: W/Bundle(32053): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-11 12:15:16.033: W/Bundle(32053): at dalvik.system.NativeStart.main(Native Method)
its refering to:
mlam.dispatchCreate(savedInstanceState);
I think you need to call super also.