Android: how to pass object between activities with object contains other objects -


i'm begginer in android , try pass object between activities object contains other objects errors appear.

a solution?

i try pass object serializable :

        lall.setonitemclicklistener(new onitemclicklistener() {             @override             public void onitemclick(adapterview<?> arg0, view v,                     int position, long arg3) {                 system.out.println(position);                 locataire l = new locataire(getresources());                 l.setnom("test");                 l.setprenom("test");                 intent intent = new intent(mainactivity.this, etat_lieux.class);                 intent.putextra("edl", l);                 startactivity(intent);                   }           }); 

and

public class locataire implements serializable{  private string ref; private string civilite; private string nom; private string prenom; private contact contact = new contact(); private adresse adresse = new adresse(); private string dg; private boolean isgarantpresent; private boolean iscolocation;  private resources res;  public locataire(resources res) {     this.res = res; } 

contact,adresse

public class contact implements serializable{

protected string tel; protected string mobile; protected string fax; protected string email; protected string www; 

and ressource context getresources() of first activity

if want pass data between activities in own app should use startactivity, startactivityforresult , onactivityresult. create bundle object , encapsulate data in putextra. retrieve object in oncreate method.

http://developer.android.com/training/basics/intents/result.html

otherwise, if want pass data between activities in app , activities in app should use explicit or implicit intents.

http://developer.android.com/training/basics/intents/sending.html


Comments