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

By -


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,


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

Paresh Mayani is a lead android developer from India. Currently, He is Sr. Software engineer at InfoStretch Solutions Pvt. Ltd. He has been developing android apps since very 1st version i.e. Android 1.5, he says he has seen days and nights of Android history. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

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