gpt4 book ai didi

android - Activity和Fragment Lifecycle,onResume是不是一个接一个触发?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:37:19 24 4
gpt4 key购买 nike

我想知道当用户从 Home Screen 返回到 Activity 时正确的顺序是什么。

会不会先执行Activity的onResume(),然后再执行Fragment的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() 执行,然后 Fragment 的 onResume() 执行。这是我的日志屏幕截图:

enter image description here

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().

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

关于android - Activity和Fragment Lifecycle,onResume是不是一个接一个触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28756577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com