Austin Wagner
Austin Wagner

Reputation: 1081

finish() not triggering onActivityResult

I want to refresh a list when the user goes back to the main Activity from a child Activity. I Overrode onActivityResult and the function is called when I press the back button on the child Activity. However, there are other ways to get back to the main Activity from the child Activity and all ways should trigger the refresh. However when I call finish from the child, onActivityResult is never called.

I use startActivityForResult to start the child activity

Intent i = new Intent(ConfGroupActivity.this, ConfGroupDetailsActivity.class);
ConfGroupActivity.this.startActivityForResult(i, 0);

And I finish the child activity like this

setResult(0);
finish();

Upvotes: 1

Views: 1370

Answers (1)

Robby Pond
Robby Pond

Reputation: 73484

When you call setResult(0) that is actually the value for RESULT_CANCELLED. You need to call

setResult(RESULT_OK);

Upvotes: 3

Related Questions