活动的样子,而在onActivityResult问题 [英] State of Activity while in onActivityResult question

查看:102
本文介绍了活动的样子,而在onActivityResult问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于该活动的状态,而在onActivityResult问题。具体而言,这是保证,要么onRestoreInstanceState或的onCreate之前已经叫onActivityResult的活动?换句话说,它是安全的假设,该活动的状态数据(成员变量等等)是可用,而在onActivityResult(假设你已经妥善处理onRestoreInstanceState和(或)的onCreate)?

I have a question about the Activity's state while in onActivityResult. Specifically, is it 'guaranteed' that either onRestoreInstanceState or onCreate have been called prior to onActivityResult for an Activity? In other words, is it safe to assume that the state data (member variables and such) of the Activity are 'usable' while in onActivityResult (assuming you have properly handled onRestoreInstanceState and or onCreate)?

推荐答案

在我的应用程序,我得到了以下工作流程:

In my app I get the following workflow:

onCreate
onStart
onRestoreInstanceState
onActivityResult
onResume

所以,是 onActivityResult 被调用后的 onRestoreInstanceState ,这样你就可以在状态计数已经完全恢复(除非你做平稳的 onResume )。

So, yes onActivityResult is called AFTER the onRestoreInstanceState, so you can count on the state has been fully restored (unless you do smth in onResume).

如果你的活动不被OS杀死,而这是在后台,那么我认为它的状态是一样的,所以你完全不用担心。 :)

If your Activity was not killed by OS while it was in the background, then I assume its state is the same, so you have nothing to worry about. :)

这篇关于活动的样子,而在onActivityResult问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆