As I understand it, if I don’t explicitly tell Android that I want to handle a configuration change in an Activity, it will get torn down and re-created on, say, an orientation change.
Let’s say that I have object O that’s an instance of some class MyCustomClass in Activity A. When the user presses a button in Activity A’s layout, we call O.startActivityB. That method will start Activity B. When Activity B gets re-created on an orientation change, I can tell (some flag was set in another or something), so Activity B immediately runs this:
setResult(RESULT_CANCELED);
finish();
return;
Who is Activity B’s parent activity at this point? Who gets the result code?
If you started Activity B from Activity A, the ‘parent’ is Activity A. The fact that an activity gets recreated for some reason doesn’t change the activity stack in any way. BTW, if you want to receive a result, you need to use
startActivityForResult(), notstartActvity().