Thanks guys! These two examples are exactly what I was looking for! :-) AudioDroid
On Jul 15, 10:57 am, MrChaz <mrchazmob...@googlemail.com> wrote: > If your class implements Parcelable then you can use add it to the > intent that you're calling via putExtra() > e.g. > ClassA bar = new ClassA(0, "foo"); > Intent i = new Intent(this, Activity.class); > i.putExtra("MyClass", bar); > > An example of implementing Parcelable is below, Serializable also > seems to require a serialVersionUID variable but eclipse can generate > that for you. > > public class ClassA implements Parcelable, Serializable{ > private int _id; > private String _name; > > public ClassA(int id, String name){ > _id = id; > _name = name; > } > > public static final Parcelable.Creator<ClassA> CREATOR = new > Parcelable.Creator<ClassA>() { > > public ClassA createFromParcel(Parcel in) { > int id = in.readInt(); > String name = in.readString(); > return new ClassA(id, name); > > } > public ClassA [] newArray(int size) { > return new ClassA [size]; > } > }; > > public int describeContents() { > // TODO Auto-generated method stub > return 0; > } > > public void writeToParcel(Parcel arg0, int arg1) { > arg0.writeInt(_id); > arg0.writeString(_name); > }} > > On Jul 15, 2:22 am, "Mapara,Harshit Nitinkumar" <hnmap...@gmail.com> > wrote: > > > Hi All, > > > Let say I have one class : > > > Class A { > > int id; String name; > > public A(int id, String name) { this.id = id; this.name = name;} > > } > > > How do I pass object of A between two Activity classes in a same > > application ? > > I came across the Parcelable interface, but I couldn't find good > > example. > > > Thanks > > Harshit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---