gpt4 book ai didi

android - onAttachedToWindow 和 onStart 之间的确切区别是什么

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:00:16 26 4
gpt4 key购买 nike

我有时看到人们使用 Activity.onAttachedToWindow 方法,但就我个人而言,我从未使用过它。在阅读它的文档时,我觉得它与 onStart() 几乎相同。

我假设的一件事是:onAttachedToWindowonCreate() 之前被调用onStop 之后被调用。

我的假设是否正确?两者的代表是什么?您什么时候使用哪个?

最佳答案

onAttachedToWindow :

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

Activity Lifecycle is explained here .

我发现“starting new activity (Theme.Dialog styled) from onAttachedToWindow() greatly improves response time if comparing to starting it from onCreate()

关于android - onAttachedToWindow 和 onStart 之间的确切区别是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8700406/

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