android - How can I pass the stringbuilder and display out in another class -


i'm able retrieve contact list contact picker, how can pass stringbuilder , display out in class. thought of using intent didn't work. please help.

 @override         public void onclick(view v) {             stringbuilder checkedcontacts= new stringbuilder();             system.out.println("............"+ma.mcheckstates.size());             for(int = 0; < name1.size(); i++)                 {                 if(ma.mcheckstates.get(i)==true)                 {                      checkedcontacts.append(name1.get(i).tostring());                      checkedcontacts.append("\n");                 }                 else                 {                     system.out.println("..not checked......"+name1.get(i).tostring());                 }              }            finish();            intent = new intent (this,secondactivity.class);          i.putextra("str",checkedcontacts);          startactivity(i);           }            }); } 

error:

intent = new intent (this,secondactivity.class);              i.putextra("str",checkedcontacts);              startactivity(i); 

use stringbuilder.tostring() pass stringbuilder intent.

 intent = new intent (this,secondactivity.class);  i.putextra("str",checkedcontacts.tostring());  startactivity(i); 

and should use finish(); after above code snippet. like

 //finish() //remove finish  intent = new intent (this,secondactivity.class);  i.putextra("str",checkedcontacts.tostring());  startactivity(i);  finish() 

and in listner can't use context object. should use getapplicationcontext() or activityname.this. like

intent = new intent (youractivityname.this, secondactivity.class);  //or  intent = new intent (getapplicationcontext(), secondactivity.class); 

Comments