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 refres开发者_Python百科h. 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();
When you call setResult(0) that is actually the value for RESULT_CANCELLED. You need to call
setResult(RESULT_OK);
精彩评论