title: Null pointer Exception in Parcelable android
body: <p>i want to send list of array objects from activity to fragments so that i create parcelable class, data's being passed and everything works fine, but when ever i pressed home button it throws NPE in writeToParcel method. Please provide me some suggestion</p>
  
  <p>Here is my parcelable class</p>
  
  <pre><code>public class SimilarAppsParcel implements Parcelable {
  
  List&lt;SimilarAppsBean&gt; similarAppsBeanList = null;
  SimilarAppsBean similarAppsBean = null;
  
  public SimilarAppsParcel(List&lt;SimilarAppsBean&gt; similarAppsBeanList) {
      super();
      this.similarAppsBeanList = similarAppsBeanList;
  }
  
  public List&lt;SimilarAppsBean&gt; getParcelList() {
      return similarAppsBeanList;
  }
  
  private SimilarAppsParcel(Parcel in) {
  
      similarAppsBean = new SimilarAppsBean();
  
      similarAppsBean.setRating(in.readFloat());
      similarAppsBean.setPrice(in.readString());
      similarAppsBean.setTitle(in.readString());
  
      similarAppsBeanList.add(similarAppsBean);
  
  }
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel parcel, int flags) {
  
      parcel.writeFloat(similarAppsBean.getRating());
      parcel.writeString(similarAppsBean.getPrice());
      parcel.writeString(similarAppsBean.getTitle());
  
      similarAppsBeanList.add(similarAppsBean);
  }
  
  public static final Parcelable.Creator&lt;SimilarAppsParcel&gt; CREATOR =
          new Parcelable.Creator&lt;SimilarAppsParcel&gt;() {
              public SimilarAppsParcel createFromParcel(Parcel in) {
                  return new SimilarAppsParcel(in);
              }
  
              public SimilarAppsParcel[] newArray(int size) {
                  return new SimilarAppsParcel[size];
              }
          };
  </code></pre>
  
  <p>}</p>
  
  <p>Here is the code how i make parcel in activity,</p>
  
  <pre><code>  private void makeSimilarAppsTabParcel(List&lt;SimilarAppsBean&gt; list) {
  
      // send the list of SimilarAppsBean to SimilarAppsParcel class to create the parcel
      SimilarAppsParcel similarAppsParcel=new SimilarAppsParcel(list);
      bundle_SimilarApps=new Bundle();
      bundle_SimilarApps.putParcelable("SimilarApps",similarAppsParcel);
  }
  </code></pre>
  
  <p>Here is the code how i receive parcel in frarment,</p>
  
  <pre><code>   Bundle bundle=this.getArguments();
     SimilarAppsParcel similarAppsParcel=bundle.getParcelable("SimilarApps");
     List&lt;SimilarAppsBean&gt; list=similarAppsParcel.getParcelList();
  </code></pre>
  
  <p>Here is my Logcat,</p>
  
  <pre><code> java.lang.NullPointerException
          at appstore.com.parcelable.SimilarAppsParcel.writeToParcel(SimilarAppsParcel.java:50)
          at android.os.Parcel.writeParcelable(Parcel.java:1254)
          at android.os.Parcel.writeValue(Parcel.java:1173)
          at android.os.Parcel.writeMapInternal(Parcel.java:591)
          at android.os.Bundle.writeToParcel(Bundle.java:1619)
          at android.os.Parcel.writeBundle(Parcel.java:605)
          at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:136)
          at android.os.Parcel.writeTypedArray(Parcel.java:1102)
          at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:381)
          at android.os.Parcel.writeParcelable(Parcel.java:1254)
          at android.os.Parcel.writeValue(Parcel.java:1173)
          at android.os.Parcel.writeMapInternal(Parcel.java:591)
          at android.os.Bundle.writeToParcel(Bundle.java:1619)
          at android.os.Parcel.writeBundle(Parcel.java:605)
          at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2269)
          at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3214)
          at android.os.Handler.handleCallback(Handler.java:725)
          at android.os.Handler.dispatchMessage(Handler.java:92)
          at android.os.Looper.loop(Looper.java:153)
          at android.app.ActivityThread.main(ActivityThread.java:5297)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:511)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>