【问题标题】:Lifecycle issue between activity and fragmentActivity 和 Fragment 之间的生命周期问题
【发布时间】:2016-03-30 16:57:37
【问题描述】:

我在 Nexus 9 上遇到问题。(系统版本 Android marshmallow) 在Android marshmallow 之前的android 系统上,当包含fragmentA 的活动状态停止时,会调用fragmentA 回调onStop。当包含 fragmentA 的活动状态被销毁时,将调用 fragmentA 回调 onDestroyView、onDestroy 和 onDetach。 官方website中描述了这些过程

最近发现在android marshmallow fragmentA上,当包含fragmentA的activity state停止时,onStop、onDestroyView、onDestroy和onDetach的回调会被连续调用。

【问题讨论】:

  • 我以前从未发现过这个问题。你能发布一些代码以便我们帮助你找出问题所在吗?

标签: android


【解决方案1】:

对不起,我终于解决了这个问题。我发布的问题不正确。当activity状态为Stopped时,会正常调用fragment回调onStop。 没有问题。当我在开发人员选项中打开“不保留活动”选项时,上述问题是由名为 onDestroy 方法的活动引起的。该问题已在this 解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-08
    • 2018-07-18
    相关资源
    最近更新 更多