java - How can I send back Bundle in Android -


i have created login form , when login success. go mainactivity.java in mainactivity have button go account settings intent sending username , password. this:

editu.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {                     intent = new intent(mainactivity.this, edituser.class);                     i.putextra("id",muser.getid());                     i.putextra("username",muser.getusername());                     i.putextra("pass",muser.getpassword());                     startactivity(i);                     //finish();         }     }); 

and in edituser.class has bundle information like:

bundle args = getintent().getextras(); 

but when finished managing on account want go home (mainactivity) tab on home button<- (picture in link below). go out of application.

link here

and realized because of condition in mainactivity

if (null == args) {         toast.maketext(this, getstring(r.string.welcome_error_message),                 toast.length_short).show();         finish();     } 

but don't know, how send intent edituser.class mainactivity.class have tried following code, didn't work. (code on edituser)

public void onbackpressed() {     intent = new intent(this,mainactivity.class);     i.putextra(user.column.id,muser.getid());     i.putextra(user.column.username,muser.getusername());     i.putextra(user.column.password,muser.getpassword());     startactivity(i); } 

first need call mainactivity using startactivityforresult(intent, requestcode);. following code:

@override protected void onactivityresult(int requestcode, int resultcode, intent data) {     super.onactivityresult(requestcode, resultcode, data);      if (resultcode == result_ok) {          //      }  } 

edit:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_pedido);      // have enable home button on action bar doing following     getactionbar().sethomebuttonenabled(true);     getactionbar().setdisplayhomeasupenabled(true);  } 

then must do:

@override public boolean onoptionsitemselected(menuitem item) {      if (item.getitemid() == android.r.id.home) {          finish();          return true;     }     else {         return menuactionbar.optionsitemselected(this, null, item)                 ? true : super.onoptionsitemselected(item);     }  } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -