的OnDestroy()调用多次 [英] OnDestroy() called multiple times

查看:597
本文介绍了的OnDestroy()调用多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到一个片段的onDestroy()方法被调用多次 - 为什么会这样?我希望只有1个电话。

I have noticed that the onDestroy() method of a fragment gets called multiple times - why would this be? I would expect only 1 call.

推荐答案

这是正常的一个活动实例获得的onDestroy() - ed分多次。例如,当您更改设备方向,活动经过的onDestroy(),然后的onCreate()。

It's normal for a single Activity instance to get onDestroy()-ed multiple times. For example, when you change the device orientation, the Activity goes through onDestroy() and then onCreate().

您可能会为完成(),当活动被封杀本身它被调用,并为每个实例发生的活动只有一次被混淆这一点。

You might be confusing this for finish(), which gets called when the Activity gets "killed" per se and happens only once per instance of your Activity.

这篇关于的OnDestroy()调用多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆