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 8232193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:44:56+00:00 2026-06-07T17:44:56+00:00

I am trying to restore an array of Objects from a savedInstanceState . I

  • 0

I am trying to restore an array of Objects from a savedInstanceState. I added each one to the Bundle individually here: (rhythm is the array of Objects)

@Override
public void onSaveInstanceState(Bundle outState){
    outState.putInt("numParts",rhythm.length);
    for(int index = 0;index<rhythm.length;++index){
        outState.putSerializable(""+index,rhythm[index].beat);
    }
    super.onSaveInstanceState(outState);
}

When the onRestoreInstanceState() method is called, I try to assign my rhythm array with the Objects from the Instance State here: (it isn’t null)

@Override 
public void onRestoreInstanceState(Bundle savedInstanceState){
    rhythm = new Part[savedInstanceState.getInt("numParts")];
    for(int index = 0; index<rhythm.length;++index){
         Object middleMan =savedInstanceState.getSerializable(""+index);
         if(middleMan==null){
             System.out.println("It's null...");
         }
    rhythm[index]=(Part) middleMan;
    }
}

It throws a ClassCastException when I parse to a Part every time. Part implements Serializable. Why is it not allowing me to parse? Will I need to do custom serialization?
Please help!

  • 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-07T17:44:58+00:00Added an answer on June 7, 2026 at 5:44 pm

    Okay I just did it as the whole array and it worked… I don’t really know why, but it did. Thanks for giving me the idea to just pass the whole array. @Error 454

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to restore my application from a Parcel (saved in a Bundle).
I am trying to restore a database from one environment to another. I backed
I am trying to restore a MySQL database from a dump file in my
I am trying to restore SQL server DB, replacing the existing one but donot
I am trying to migrate microsoft office settings from one system to other system
I am trying to restore MySQL database data from a dump file, using C#
I am trying to restore a database (from file thedb.bak ). I am using
I'm trying to restore a database from an sql file through phpmyadmin import function.
Running sql server 2005 I have database A. I am trying to restore from
I'm trying to overwrite our dev database from our live one. I selected the

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.