开发者

finish() not triggering onActivityResult

开发者 https://www.devze.com 2023-01-04 23:00 出处:网络
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.

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消