gpt4 book ai didi

android - 如何检测 View 的父 Activity 是否被销毁

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

我想在 Activity 被销毁时在 View 中进行一些清理。当 Activity 被销毁时,有什么方法可以在 View 中获得回调?我尝试使用 onDetachedFromWindow,但我不确定这样做是否正确。

最佳答案

如果您想在不重载 View.onDetachedFromWindow() 方法的情况下获得回调,您可以使用 View.addOnAttachStateChangeListener()方法,它将回调监听器作为单个参数。

关于android - 如何检测 View 的父 Activity 是否被销毁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3147659/

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