Returning intent result when Activity is closed by back button
Try this :
@Override
public void onBackPressed() {
// super.onBackPressed();
Intent intent = new Intent();
intent.putIntegerArrayListExtra(SELECTION_LIST, selected);
setResult(RESULT_OK, intent);
finish();
}
Since this question is still getting attention, i am posting a more correct answer than the one i accepted two years ago, thanks for MasterGaurav for the tip.
@Override
public void onBackPressed() {
Intent intent = new Intent();
intent.putIntegerArrayListExtra(SELECTION_LIST, selected);
setResult(RESULT_OK, intent);
super.onBackPressed();
}