onActivityResult()及onResume() [英] onActivityResult() & onResume()
问题描述
有人能告诉我,这被称为第一,它是 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.
这篇关于onActivityResult()及onResume()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!