How can I pass extras to activity which is previous in backstack? When user press BACK button I would like to do something like:
intent.putExtra("playlist", playlist);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
I guess it has to be in onStop() method but how can I identify an activity that will be resumed? I found somthing like getParentActivityIntent() but I cannot understand documentation clearly and I do not know if it is what I need.
-----EDIT------
I will try to explain it other way.
in ActivityA I start a new ActivityB and pass some Extra:
Intent intent = new Intent(this, ActivityB.class);
int var = 3;
intent.putExtra("var", var);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
in ActivityB I can do:
if (getIntent().hasExtra("var")) {
var = getIntent().getIntExtra("var");
var = var + 2;
}
Now after pressing BACK button the user go back to ActivityA. Where var = 3. But I would like to pass the new value of var from ActivityB. I would like to have in ActivityA var = 5. How can I do this? I cannot find in documentation a reference to "previous" activity (in this case to ActivityA from ActivityB).