Android – Send object from one activity to another Activity using Intent

By -

Here is a simple example about how to pass custom class object from one activity to another activity. To pass an object, your custom class object must be serialized, to do so just implement the Serializable interface.

For example:


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) { = 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");
Paresh Mayani

Lazy android developer, exploring the horizon of android development since 7 years, currently working as a Technical Lead - Android at Simform Solutions, India. Former Application Architect at KarConnect. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

Loading Facebook Comments ...
Loading Disqus Comments ...