Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7935755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:01:07+00:00 2026-06-03T22:01:07+00:00

Hi i currently have an Activity that hosts a tab view, and each tab

  • 0

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);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:01:08+00:00Added an answer on June 3, 2026 at 10:01 pm

    I think you need to call super also.

    @Override
    protected void onSaveInstanceState(Bundle outState)
    {
        // SAVE YOUR DATA IN "outState"
        super.onSaveInstanceState(outState);
    }
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        //RECOVER YOUR DATA FROM "savedInstanceState"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a class called clientActivity that contains a finger paintig activity that
I'am currently working on GWTs Activity-Place implementation. Now I have found problem with the
Currently I have a TabHost implemented with 3 tabs each containing a separate activity.
I currently have an Activity that when it gets displayed a Notification will also
I currently have a simple list view adapter that holds two rows of text.
In my application, I currently have several activities that consist of a TextView and
I currently have a tab layout with 2 tabs, one tab with a list
I have an Activity that plays some audio from within a ListActivity . The
I currently have an activity that does not have an xml layout file. All
I currently have an activity with some buttons. In my xml, buttons are defined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.