Hi,
Here i am going to discuss on passing your custom class object from one activity to another activity. You might have required to pass object among activities.
First all, your custom class should implement Serializable interface.
For example,
import java.io.Serializable;
public class Student implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
int rollno;
String name;
public int getRollno() {
return rollno;
}
public void setRollno(int rollno) {
this.rollno = rollno;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Now To pass the object of Student class From Activity ‘A’ to activity ‘B’:
Student stud = new Student();
Intent aActivity = (A.this, B.class);
intent.putExtra("StudentObject", stud);
To retrieve object in second Activity i.e. in ‘B’ activity, write the below line:
Student studObject = getIntent().getSerializableExtra("StudentObject");