Skip to content

Instantly share code, notes, and snippets.

@ekirastogi
Created December 22, 2015 05:25
Show Gist options
  • Save ekirastogi/ce17387134104e4cc1ef to your computer and use it in GitHub Desktop.
Save ekirastogi/ce17387134104e4cc1ef to your computer and use it in GitHub Desktop.
public class ActivityOne extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Person person = new Person("Ekansh","[email protected]","New Delhi, India");
Intent intent = new Intent(ActivityOne.this, ActivityTwo.class);
intent.putExtra(DataUtil.PERSON, person);
startActivity(intent);
}
}
public class ActivityTwo extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Person person = (Person) getIntent().getSerializableExtra(DataUtil.PERSON);
}
}
public interface DataUtil {
String PERSON = "person";
}
class Person implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String email;
private String address;
public Person(){}
public Person(String name,String email,String address){
this.name=name;
this.email=email;
this.address=address;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment