title: Using Parceble to communicate between activities
body: <p>So I am trying to pass my object from one activity to another using <code>Parceble</code> provided in android as it is the right thing to use in this case.</p>
  
  <p>This is my Bean Class which I have <code>serialized</code> by implementing <code>Parceble</code></p>
  
  <p><strong>Customer.class</strong></p>
  
  <pre><code>public class Customer implements Parcelable {
  
      int a;
      String name;
  
      public Customer(int ab , String n) {
      this.a=ab;
      this.name=n;
      }
  
      public int getA() {
          return a;
      }
  
      public void setA(int a) {
          this.a = a;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
  
      public Customer(Parcel in) {
           a= in.readInt();   
           name= in.readString();
          //readFromParcel(in);
      }
  
      @Override
      public int describeContents() {
          // TODO Auto-generated method stub
          return 0;
      }
  
      @Override
      public void writeToParcel(Parcel dest, int flags) {
          dest.writeString(name);
          dest.writeInt(a);
      }
  
      public static final Parcelable.Creator&lt;Customer&gt; CREATOR= new Parcelable.Creator&lt;Customer&gt;() {
  
          @Override
          public Customer createFromParcel(Parcel source) {
              return new Customer(source);
          }
  
          @Override
          public Customer[] newArray(int size) {
              return new Customer[size];
          }
      };
  
  
      private void readFromParcel(Parcel in) {
  
          a= in.readInt();    
          name= in.readString();
     }
  }
  </code></pre>
  
  <p><strong>MainActivity.class</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
  
      Button b;
      Customer c;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          b=(Button) findViewById(R.id.button1);
  
          c=new Customer(33,"nn");
  
          b.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  Intent i=new Intent(MainActivity.this,CustomActivity.class);
                  i.putExtra("myobj", c);
                  startActivity(i);
              }
          });
      }
  
  }
  </code></pre>
  
  <p><strong>CustomActivity.class</strong></p>
  
  <pre><code>public class CustomActivity extends Activity{
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          Intent it=getIntent();
          Customer c=(Customer)it.getParcelableExtra("myobj");
  
          System.out.println("and object is "+c.getA()+"/"+c.getName());
      }
  }
  </code></pre>
  
  <p><strong>And this is my output in Logcat:</strong></p>
  
  <pre><code>05-15 12:02:56.014: I/System.out(25581): and object is 2/null
  </code></pre>