Other answers were not working when I put setResult
in onBackPressed
. Commenting call to super onBackPressed
and calling finish
manually solves the problem:
@Override
public void onBackPressed() {
//super.onBackPressed();
Intent i = new Intent();
i.putExtra(EXTRA_NON_DOWNLOADED_PAGES, notDownloaded);
setResult(RESULT_OK, i);
finish();
}
And in first activity:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == QUEUE_MSG) {
if (resultCode == RESULT_OK) {
Serializable tmp = data.getSerializableExtra(MainActivity.EXTRA_NON_DOWNLOADED_PAGES);
if (tmp != null)
serializable = tmp;
}
}
}