title: Android: Parcelable.writeToParcel and Parcelable.Creator.createFromParcel are never called
body: <p>I'm totally new to posting questions on here, however I have been reading a lot on here for years. Normally I always am able to find my answers by thoroughly searching the web, but this time I am at a loss...</p>
  
  <p>After having spent yet another day of trying to figure out why this is not working I decided to ask for help, hoping you guys can give me a few pointers, or better, a solution.</p>
  
  <p>The problem:
  In an Android game I have come to the point where I have to make the application remember its state when a user e.g. presses the HOME-screen button. After some searches I realised that in order to make my classes initialize back to their appropriate states after re-opening the application I had to support the Parcelable interface to pass them with the Bundle.</p>
  
  <p>In my onStop and onStart functions I respectively save and restore the game state to and from a Bundle, however when I call the putParcelable and getParcelable functions on the Bundle the object's writeToParcel and createFromParcel functions are never called.</p>
  
  <p>Fearing that this may have been due to the relative complexity of the game I figured I had best create a very simple application to try to get it to work.</p>
  
  <p>Based on many Parcelable examples I have seen online, this became my class:</p>
  
  <pre><code>public class ParcelableTest implements Parcelable {
    int id;
  
    public ParcelableTest(int newID)
    {
      id = newID;
    }
  
    private ParcelableTest(Parcel in) {
        readFromParcel(in);
    }
  
    public void writeToParcel(Parcel out, int arg1) {
        writeToParcel(out);
    }
  
    public void writeToParcel(Parcel out) {
      Log.v("ParcelableTest","Writing to parcel");
        out.writeInt(id);
    }
  
    public void readFromParcel(Parcel in) {
        id = in.readInt();
    }
  
    public int describeContents() {
        return 0;
    }
  
    public static final Parcelable.Creator&lt;ParcelableTest&gt; CREATOR = new
    Parcelable.Creator&lt;ParcelableTest&gt;() {
        public ParcelableTest createFromParcel(Parcel in) {
            Log.v("ParcelableTest","Creating from parcel");
                return new ParcelableTest(in);
        }
  
        public ParcelableTest[] newArray(int size) {
                return new ParcelableTest[size];
        }
    };
  }
  </code></pre>
  
  <p>And from my Main activity I would call the following functions to save / restore the data:</p>
  
  <pre><code>public Bundle saveToBundle(Bundle savedState)
      {
        savedState.putParcelable("Test1",mTest1);
        savedState.putParcelable("Test2",mTest2);
        return savedState;
      }
      public void restoreFromBundle(Bundle savedState)
      {
        mTest1 = savedState.getParcelable("Test1");
        mTest2 = savedState.getParcelable("Test2");
  
      }
  </code></pre>
  
  <p>But for some reason neither of the functions (with the putParcelable and getParcelable functions) will result in the appropriate Parcelable calls in my test class.</p>
  
  <p>The strangest thing is that it does somehow read the correct values (I have tried with more variables in the class), but my debugging and my log shows that tha application never gets to writeToParcel and createFromParcel.</p>
  
  <p>What am I missing here?</p>
  
  <p>Any help / thoughts would be appreciated.</p>