title: List of custom object and Parcelable give NullPointerException
body: <p>I am trying to understand principles of Parcelable in Android and I wrote this simply code to find what is going on when I try to "parcel" a list of custom object - it gives my NullPointerException</p>
  
  <p>Here is my code :</p>
  
  <pre><code>package cz.united121.android.testpupose.Objects.HelperObject;
  
  import android.os.Parcel;
  import android.os.Parcelable;
  
  public class MyString implements Parcelable {
  private static final String TAG = MyString.class.getName();
  
  
  String mString;
  
  public MyString(){
  
  }
  
  public MyString(String mString){
      this.mString = mString;
  }
  
  public MyString(Parcel in){
      mString = in.readString();
  }
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      dest.writeString(mString);
  }
  
  public static final Parcelable.Creator&lt;MyString&gt; CREATOR
          = new Parcelable.Creator&lt;MyString&gt;() {
      public MyString createFromParcel(Parcel in) {
          return new MyString(in);
      }
  
      public MyString[] newArray(int size) {
          return new MyString[size];
      }
  };
  
  }
  </code></pre>
  
  <p>Second class has List of MyString</p>
  
  <pre><code>package cz.united121.android.testpupose.Objects;
  
  import android.os.Parcel;
  import android.os.Parcelable;
  import android.util.Log;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import cz.united121.android.testpupose.Objects.HelperObject.MyString;
  public class CustomSmall implements Parcelable {
  private static final String TAG = CustomSmall.class.getName();
  
  
  int mId;
  String mName;
  int mDummy;
  List&lt;MyString&gt; mStringList;
  
  public CustomSmall(){
      Log.d(TAG,"CustomSmall()");
      mStringList = new ArrayList&lt;&gt;();
  }
  
  public CustomSmall(Parcel in){
      Log.d(TAG,"CustomSmall(Parcel in)");
      mId = in.readInt();
      mName = in.readString();
      mDummy = in.readInt();
      in.readTypedList(mStringList,MyString.CREATOR);
  }
  
  public CustomSmall(int mId, String mName, int mDummy, List&lt;MyString&gt; mStringList){
      Log.d(TAG, "CustomSmall(int mId, String mName, int mDummy, List&lt;MyString&gt; mStringList)");
      this.mId = mId;
      this.mName = mName;
      this.mDummy = mDummy;
      this.mStringList = mStringList;
  }
  
  @Override
  public int describeContents() {
      Log.d(TAG,"describeContents()");
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      Log.d(TAG,"writeToParcel(Parcel dest, int flags)");
      dest.writeInt(mId);
      dest.writeString(mName);
      dest.writeInt(mDummy);
      dest.writeTypedList(mStringList);
  }
  
  public static final Parcelable.Creator&lt;CustomSmall&gt; CREATOR
          = new Parcelable.Creator&lt;CustomSmall&gt;() {
      public CustomSmall createFromParcel(Parcel in) {
          Log.d(TAG,"createFromParcel(Parcel in)");
          return new CustomSmall(in);
      }
  
      public CustomSmall[] newArray(int size) {
          Log.d(TAG,"newArray(int size)");
          return new CustomSmall[size];
      }
  };
  }
  </code></pre>
  
  <p>and here is how I test it 
  One activity has this after click:</p>
  
  <pre><code>    MyString myString1 = new MyString("a");
      MyString myString2 = new MyString("b");
      MyString myString3 = new MyString("c");
      MyString myString4 = new MyString("d");
  
      List&lt;MyString&gt; myStringList1 = new ArrayList&lt;&gt;();
      myStringList1.add(myString1);
      myStringList1.add(myString4);
  
      List&lt;MyString&gt; myStringList2 = new ArrayList&lt;&gt;();
      myStringList1.add(myString1);
      myStringList1.add(myString2);
      myStringList1.add(myString3);
      myStringList1.add(myString4);
  
      CustomSmall customSmall_1 = new CustomSmall(1,"First",42,myStringList1);
      CustomSmall customSmall_2 = new CustomSmall(2,"Second",88,myStringList2);
  
      bundle.putParcelable(CUSTOM_SMALL + "1",customSmall_1);
      bundle.putParcelable(CUSTOM_SMALL + "2",customSmall_2);
      Bundle b = new Bundle();
      Intent toNavigationDrawer = new Intent(MainActivity.this,NavigationDrawerTest.class);
      toNavigationDrawer.putExtras(b);
      startActivity(toNavigationDrawer);
  </code></pre>
  
  <p>and class NavigationDrawer has this :</p>
  
  <pre><code>    Bundle bundle = getIntent().getExtras();
      CustomSmall customSmall_1 = bundle.getParcelable(CUSTOM_SMALL + "1");
      CustomSmall customSmall_2 = bundle.getParcelable(CUSTOM_SMALL + "2");
  </code></pre>
  
  <p>but i gives my error :</p>
  
  <pre><code>Unable to start activity ComponentInfo{cz.united121.android.testpupose/cz.united121.android.testpupose.NavigationDrawerTest}: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
  ...
  Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
  ...
  at cz.united121.android.testpupose.Objects.CustomSmall.&lt;init&gt;(CustomSmall.java:34)
          at cz.united121.android.testpupose.Objects.CustomSmall$1.createFromParcel(CustomSmall.java:64)
          at cz.united121.android.testpupose.Objects.CustomSmall$1.createFromParcel(CustomSmall.java:61)
  </code></pre>
  
  <p>and CustomSmall.java:34 is line :</p>
  
  <pre><code> in.readTypedList(mStringList,MyString.CREATOR); in public CustomSmall(Parcel in){
  </code></pre>
  
  <p>Anyone know the solution ? I am trying to solve this almost 2 days. Big thanks in advance</p>