[英]Android: Is onResume always called after onCreate?
I need to know if there is ever an instance when onResume
will be called before onCreate
has been called at least once.我需要知道在至少调用一次
onCreate
之前是否会调用onResume
的实例。 Thanks.谢谢。
Edit: Judging by the activity life cycle, it doesn't seem so.编辑:从活动生命周期来看,似乎并非如此。 But I want to double check.
但我想仔细检查一下。
onResume()
will never be called before onCreate()
. onResume()
永远不会在onCreate()
之前被调用。
Read more about it in the Activity Lifecycle在活动生命周期中阅读更多相关信息
onResume()
将始终在 Activity 进入前台时被调用,但它永远不会在onCreate()
之前执行。
you can refer the website for more details您可以参考网站了解更多详情
http://developer.android.com/training/basics/activity-lifecycle/starting.html http://developer.android.com/training/basics/activity-lifecycle/starting.html
I had an issue in which overridden onCreate was not getting called.我遇到了一个问题,即没有调用覆盖的 onCreate。 I tried debugging and logging and i found oncreate not getting called.
我尝试了调试和日志记录,但发现 oncreate 没有被调用。
Turns out that i override wrong onCreate原来我覆盖了错误的 onCreate
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
This is the correct one.这是正确的。
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
Posting in the hope that it might help some poor soul.发帖希望它可以帮助一些可怜的灵魂。 :)
:)
So the correct onCreate() will always get called before onResume所以正确的 onCreate() 总是会在 onResume 之前被调用
Note: This answer only an additional one to complement the accepted answers .注意:此答案只是补充已接受答案的补充。
As previous answers say:正如之前的回答所说:
onResume() will never be called before onCreate().
Read more about it in the Activity Lifecycle and Starting an Activity .在Activity Lifecycle和Starting an Activity 中阅读有关它的更多信息。
Below the complete image of Activity lifecycle including Fragment Lifecycle from android-lifecycle :在Activity 生命周期的完整图像下方,包括来自android-lifecycle 的Fragment Lifecycle :
the activity has its own lifecycle .活动有自己的生命周期。 just read and look at the nice graph here:
只需阅读并查看这里的漂亮图表:
http://developer.android.com/reference/android/app/Activity.html http://developer.android.com/reference/android/app/Activity.html
onResume doesn't suppose to run before onCreate , so you assume correctly . onResume 不应该在 onCreate 之前运行,所以你假设正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.