How can I pass an object of a custom type from one Activity to another using the
putExtra()
method of the class Intent?
By far the easiest way IMHO to parcel objects. You just add an annotation tag above the object you wish to make parcelable.
An example from the library is below https://github.com/johncarl81/parceler
@Parcel
public class Example {
String name;
int age;
public Example(){ /*Required empty bean constructor*/ }
public Example(int age, String name) {
this.age = age;
this.name = name;
}
public String getName() { return name; }
public int getAge() { return age; }
}