onActivityResult()及onResume()onActivityResult、onResume

由网友(孟婆,来碗内牛满面)分享简介:有人能告诉我,这被称为第一,它是 onActivityResult()还是 onResume()?例如:Could someone tell me which gets called first, is it onActivityResult() or is it onResume()?Example:活动A调...

有人能告诉我,这被称为第一,它是 onActivityResult()还是 onResume()? 例如:

Could someone tell me which gets called first, is it onActivityResult() or is it onResume()? Example:

活动A调用 startActivityForResult()启动活动B. B执行,完成并返回结果为A,但A的方法被称为第一, onActivityResult() onResume()

Activity A calls startActivityForResult() to start Activity B. B executes, completes and returns a result to A, but which method of A is called first, onActivityResult() or onResume()?

我知道有人已经参照活动文档回答了这个问题,但是我找不到在那里我自己。

I know someone has answered this question already by referring to the Activity Docs, however I couldn't find in there myself.

推荐答案

首先调用 onActivityResult()然后 onResume()

从文档中引用:

保护无效onActivityResult(INT   请求code,INT结果code,意图   数据)

protected void onActivityResult (int requestCode, int resultCode, Intent data)

自:API级别1调用时   活动中,推出了出口,使   你请求code,你开始了它   有,C时,结果$ C $回来,   从它的任何附加数据。该   因此code,如果将被RESULT_CANCELED   活动明确地返回,   没有返回任何结果,或崩溃   在其操作。 您将收到   此调用之前立即   onResume()当你的活动   重新启动。

Since: API Level 1 Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. The resultCode will be RESULT_CANCELED if the activity explicitly returned that, didn't return any result, or crashed during its operation. You will receive this call immediately before onResume() when your activity is re-starting.

阅读全文

相关推荐

最新文章