Android- Going back to Previous Activity with different Intent value -


i have application has transition:

 -> b -> c -> d-> c 

upon entering c , have check flag. have pass intent (let intentx = false) d. after doing in d , go c after pressing button. did pass again intentx value true, startactivity c again. happen created activity c.

what want happen not have start new activity c, use previous c calling super.onbackpressed(). cannot pass new value of intentx. there other way, achieve want. might have missed some.

what want startactivityforresult(). when go c d, instead of using startactivity() use instead startactivityforresult(). when want return d c use setresult() can include intent object extras pass c.

i don't recommend doing in onbackpressed() if don't have because not user expects. instead, should return data event such button click.

so, in c like

 intent = new intent(new intent(c.this, d.class);  startactivityforresult(i, 0); 

then in d when ready return

 intent = new intent();  i.putextra();  // insert extras here  setresult(0, i); 

then when return c enter method (taken docs)

protected void onactivityresult(int requestcode, int resultcode,          intent data) {      if (requestcode == pick_contact_request) {          if (resultcode == result_ok) {              // contact picked.  here display              // user.              startactivity(new intent(intent.action_view, data));               /*                  can sent through data                 using data.getstringextra("somekey");                  assuming string              */           } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -