意向的onDestroy()一直被称为与后退按钮 [英] Intent onDestroy() always being called with back button

查看:105
本文介绍了意向的onDestroy()一直被称为与后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎有相反的问题的话题我所遇到的所有其他职务。其他人发现的onDestroy()并不总是叫,但我觉得它的总是并立即

I appear to have the opposite issue to every other post on the topic I have come across. Others find that onDestroy() is not always called but I find it always and immediately is.

我检查是否被调用以下内容:

I am checking whether it is called with the following:

@Override
protected void onDestroy() {
    super.onDestroy();
    Log.d(TAG, "onDestroy");
}

本日志code要么单击后退或使用我的动作条按钮,这只是调用家庭活动作为一个意图后,立即触发。

This log code is triggered immediately after either clicking back or using my actionbar button which just calls the home activity as an intent.

我环顾四周,但大家都说生命周期应该是这样的:的http://开发商。 android.com/images/activity_lifecycle.png

I have looked around but everyone says the lifecycle should look like this: http://developer.android.com/images/activity_lifecycle.png

此行​​为并不局限于单一的应用程序;我曾尝试下载一些例如code和增加在上面调试code才发现相同的行为。它也并不限于单个机器人版本;我曾尝试在模拟器中2.1和2.3,也4.0.2物理设备上。

This behaviour is not limited to a single app; I have tried downloading some example code and adding in the above debugging code only to find the same behaviour. It is also not limited to a single android version; I have tried 2.1 and 2.3 in the emulator and also 4.0.2 on a physical device.

什么,我可能是做错了任何想法?

Any ideas of what I might be doing wrong?

推荐答案

pressing 返回键居然挑起完成()方法上您的活动,并导致你的活动是 paused-> stopped->摧毁

pressing back key actually provokes finish() method on your activity, and it causes your activity to be paused->stopped->destroyed

所以在技术上如预期这种行为的功能。

so technically this behavior is functional as expected.

这篇关于意向的onDestroy()一直被称为与后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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