title: android: issue in parsing Parcelable object from service to activity using intent
body: <p>I tried to pass the <code>Order</code> (see below for <code>Order</code> object details) object from Android Service (<code>IntentService</code>) to activity using android <code>Intent</code>, I tried in the following way: </p>
  
  <p>in the <code>Service</code> class:</p>
  
  <pre><code>Bundle b = new Bundle();
  b.putParcelable("lastOrder", serverResponse.getOrder());
  </code></pre>
  
  <p>In the <code>Activity</code>:</p>
  
  <pre><code>Bundle resultData
  Order lastOrder = (Order) resultData.getParcelable("lastOrder");
  </code></pre>
  
  <p>but I got the following errors:</p>
  
  <ol>
  <li>“ClassNotFound exception when unmarshalling” so I fixed the issue refering to following link 
  <a href="http://androidideasblog.blogspot.com/2010/08/classnotfound-exception-when.html" rel="nofollow">http://androidideasblog.blogspot.com/2010/08/classnotfound-exception-when.html</a></li>
  <li>now I'm getting “readBundle: bad magic number”</li>
  <li>Unmarshalling unknown type code</li>
  </ol>
  
  <p>Can some help me on this?</p>
  
  <pre><code>    public class Order implements Parcelable {
         private Long order_id;
         private String order_source;
         private ArrayList&lt;OrderItem&gt; items;
         private Shop shop;
          .....
  
           @Override
          public void writeToParcel(Parcel out, int flags) {
           out.writeLong(order_id);
           Bundle b = new Bundle();
              b.putParcelableArrayList("OrderItems", items);
              out.writeBundle(b);
  
             // out.writeList(items);
              out.writeParcelable(shop, 1);
          }
  
           public static final Parcelable.Creator&lt;Order&gt; CREATOR = new Parcelable.Creator&lt;Order&gt;() {
              public Order createFromParcel(Parcel in) {
                  return new Order(in);
              }
  
              public Order[] newArray(int size) {
                  return new Order[size];
              }
          };
  
          private Order(Parcel in) {
             this.order_id = in.readLong();
               Bundle b = in.readBundle(OrderItem.class.getClassLoader());        
              this.items = b.getParcelableArrayList("OrderItems");
  
              //this.items = in.readArrayList(getClass().getClassLoader());
              this.shop = in.readParcelable(Shop.class.getClassLoader());
          }
      }
  
   // // // // // // // // // // // // // // // // // // // // // // // // //
     public class Shop implements Parcelable {
  
          private Long shop_id;
          private String shop_date;
          private String shop_code;   
          .....
           @Override
          public void writeToParcel(Parcel out, int flags) {
              out.writeLong(shop_id);
              out.writeString(shop_date);
              out.writeString(shop_code);
          }
  
           public static final Parcelable.Creator&lt;Shop&gt; CREATOR = new Parcelable.Creator&lt;Shop&gt;() {
              public Shop createFromParcel(Parcel in) {
                  return new Shop(in);
              }
  
              public Shop[] newArray(int size) {
                  return new Shop[size];
              }
          };
  
          private Shop(Parcel in) {
              this.shop_id = in.readLong();
              this.shop_date = in.readString();
              this.shop_code = in.readString();
              }
      }
  
  // // // // // // // // // // // // // // // // // // // // // // // // //
      public class OrderItem implements Parcelable {
          private Long order_item_id;
          private Product product;
          private ProductCategory product_Category;
          private ArrayList&lt;OrderExtra&gt; extras;
  
          .....
           @Override
          public void writeToParcel(Parcel out, int flags) {
              out.writeLong(order_item_id);
              out.writeParcelable(product,1 );
              out.writeParcelable(product_Category, 1);
              //out.writeList(extras); http://androidideasblog.blogspot.com/2010/08/classnotfound-exception-when.html
               Bundle b = new Bundle();
              b.putParcelableArrayList("OrderExtras", extras);
              out.writeBundle(b);
          }
  
           public static final Parcelable.Creator&lt;OrderItem&gt; CREATOR = new Parcelable.Creator&lt;OrderItem&gt;() {
              public OrderItem createFromParcel(Parcel in) {
                  return new OrderItem(in);
              }
  
              public OrderItem[] newArray(int size) {
                  return new OrderItem[size];
              }
          };
  
          private OrderItem(Parcel in) {
              this.order_item_id = in.readLong();
              this.product = in.readParcelable(getClass().getClassLoader());
              this.product_Category = in.readParcelable(getClass().getClassLoader());
              //this.extras = in.readArrayList(getClass().getClassLoader());
  
              Bundle b = in.readBundle(OrderExtra.class.getClassLoader());        
              this.extras = b.getParcelableArrayList("OrderExtras");
  
          }
      }
      // // // // // // // // // // // // // // // // // // // // // // // // //
      public class Product implements Parcelable {
          private Long product_id;
          private String product_date;
          private String product_name;
  
          .....
           @Override
          public void writeToParcel(Parcel out, int flags) {
          out.writeLong(product_id);
              out.writeString(product_date);
              out.writeString(product_name);
          }
  
            public static final Parcelable.Creator&lt;Product&gt; CREATOR = new Parcelable.Creator&lt;Product&gt;() {
              public Product createFromParcel(Parcel in) {
                  return new Product(in);
              }
  
              public Product[] newArray(int size) {
                  return new Product[size];
              }
          };
  
          private Product(Parcel in) {
              this.product_id = in.readLong();
              this.product_date = in.readString();
              this.product_name = in.readString();
          }
      }
  
  // // // // // // // // // // // // // // // // // // // // // // // // //
      public class ProductCategory implements Parcelable {
          private Long product_category_id;
          private String product_category_date;
          private String product_category_name;
  
              .....
               @Override
          public void writeToParcel(Parcel out, int flags) {
             out.writeLong(product_category_id);
              out.writeString(product_category_date);
              out.writeString(product_category_name);
  
          }
  
          public static final Parcelable.Creator&lt;ProductCategory&gt; CREATOR = new Parcelable.Creator&lt;ProductCategory&gt;() {
              public ProductCategory createFromParcel(Parcel in) {
                  return new ProductCategory(in);
              }
  
              public ProductCategory[] newArray(int size) {
                  return new ProductCategory[size];
              }
          };
  
          private ProductCategory(Parcel in) {
              this.product_category_id = in.readLong();
              this.product_category_date = in.readString();
              this.product_category_name = in.readString();
          }
      }
  
      // // // // // // // // // // // // // // // // // // // // // // // // //
      public class OrderExtra implements Parcelable {
          private Long order_item_extra_id;
          private String order_item_extra_price;
          private String order_item_extra_name;
  
           @Override
          public void writeToParcel(Parcel out, int flags) {
           out.writeLong(order_item_extra_id);
             out.writeString(order_item_extra_price);
              out.writeString(order_item_extra_name);
          }
  
  
           public static final Parcelable.Creator&lt;OrderExtra&gt; CREATOR = new Parcelable.Creator&lt;OrderExtra&gt;() {
              public OrderExtra createFromParcel(Parcel in) {
                  return new OrderExtra(in);
              }
  
              public OrderExtra[] newArray(int size) {
                  return new OrderExtra[size];
              }
          };
  
          private OrderExtra(Parcel in) {
              this.order_item_extra_id = in.readLong();
              this.order_item_extra_price= in.readString();
              this.order_item_extra_name= in.readString();
          }
      }
  </code></pre>