Activity 和 Fragment Lifecycle,onResume 是否一个接一个触发?

Activity and Fragment Lifecycle, does the onResume fire one after the other?

我想知道当用户 returns 从 Home ScreenActivity 时正确的顺序是什么。

会先执行Activity's onResume(),然后执行Fragment's onResume()吗?它是按顺序做,还是同时做?

我在 Fragment 的 onResume() 中添加了一些代码,但在 Activity 的 onResume() 之后似乎没有触发。

I am wondering what the proper order goes when a user returns to an Activity from the Home Screen.

Activity 的 onResume() 执行,然后片段的 onResume() 执行。这是我的日志屏幕截图:

Will the Activity's onResume() execute first, and then the Fragment's onResume() execute after? Does it do it in order, or will it do it concurrently?

是的,这两个onResume()方法是顺序执行的,因为都是在主线程(也叫ui线程,是单线程)执行,所以不存在并发问题。

I put some code in my Fragment's onResume() but it doesn't seem to be firing after the Activity's onResume().

我觉得你的代码有问题,你可以再检查一下或者post在这里,所以有人可能会指出你的错误。

片段onResume()onPause()只有在活动onResume()onPause()被调用后才会被调用。它们与 Activity.

紧密耦合

Read the Fragment Lifecycle section of this article.