放置到的onDestroy()内的onPause()的调用:好主意,以保证活动的破坏? [英] Placing a call to onDestroy() inside onPause(): good idea to guarantee activity destruction?

查看:128
本文介绍了放置到的onDestroy()内的onPause()的调用:好主意,以保证活动的破坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有获取singleinstance模式下启动的活动。它只是服务的目的时调用,并没有任何算账。

I have an activity that gets launched in singleinstance mode. It only serves a purpose when invoked, and none whatsoever afterwards.

现在我当然有它操纵所以从理论上讲,用户不能离开活动而不终止它。这就是说,我知道的应用程序,允许绕过这种行为,如clutchpad。

Now of course I have it rigged so theoretically speaking the user can't leave the activity without terminating it. That said, I know apps that allow to bypass this sort of behaviour, such as clutchpad.

问:如果我要拍真的,真的相信我的活动,当远离它死了(也就是说,如果它在backstack下跌),它是保存/建议中的onPause打电话的onDestroy,或者是一个坏主意

Question: if I wanted to make really, really sure my activity died upon moving away from it (ie, if it fell in the backstack), is it save/recommended to call onDestroy within onPause, or is it a bad idea.

如果一个坏主意,那么什么是实现这一目标的正确方式?

If a bad idea, then what is the correct way of achieving this?

感谢您!

推荐答案

的onDestroy()在活动正在并没有结束你的活动,它是被系统调用销毁。你覆盖它,这样可以清理的活动(例如阻止你从它推出其他线程),当活动结束。你或许应该避免调用它,只是让需要的时候系统调用它。如果你想结束你的活动,请拨打完成()代替。

onDestroy() does not end your activity, it is called by the system when the activity is being destroyed. You override it so that you can clean up your activity (e.g. stop other threads you have launched from it) when the activity ends. You probably should avoid calling it, and just let the system call it for you when needed. If you wish to end your activity, call finish() instead.

这篇关于放置到的onDestroy()内的onPause()的调用:好主意,以保证活动的破坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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