android - Send data to a parent activity onBackPressed -


this question has answer here:

is there way send updated data parent activity when pressed? i'd update data in bundle, don't see how access it.

for example, have gallery activity opens image viewer. user scrolls through dozen images , backs out gallery. ideal update focal image in gallery last image viewed.

at moment can't think of how without global setting.

here's pseudo code of i'd (although wouldn't work):

child:

@override public void onbackpressed() {     getintent().setdata(currentimage);  // not right intent,     super.onbackpressed(); } 

parent:

@override public void onresume() {     super.onresume();     uri photofocus = getintent().getdata();     if (photofocus != null)         setphotofocus(photofocus); } 

you can

startactivityforresult()

from parent activity when start childactivity. onbackpressed, can call setresult() in childactivity.

in parentactivity code come callback :

protected void onactivityresult(int requestcode, int resultcode, intent data) { }

where can extract result set in setresult method

or

use sharedpreferences


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -