安卓:在应用类的onDestroy()或类似的方法 [英] Android: onDestroy() or similar method in Application class

查看:541
本文介绍了安卓:在应用类的onDestroy()或类似的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在扩展应用程序类中的一些需要方面的全局变量工作。我知道有的onCreate()在任何其他的onCreate()在活动之前调用应用程序类的方法,但我想知道是否有的onDestroy(),或在应用程序类类似的方法,可以被覆盖,这样我就可以存储在持久性存储器,注销监听器变量,并发送最后一条消息给服务器之前,应用程序就会被杀死?如果没有,是否有任何其他方式做到这一点?

I am extending Application class to work with some global variables that need context. I know there is onCreate() method in the Application class that gets called before any other onCreate() in activities, but I would like to know if there is onDestroy() or similar method in the Application class that could be overridden so that I would be able to store variables in persistent memory, unregister listener and send last message to server before app process gets killed? If not, is there any other way to do that?

推荐答案

有没有这样的回拨生产设备的应用程序类。

There is no such call back on a production device for the Application class.

你想做的事,通常应做的更改后的权利,或者这个事情在的onPause()各自的应用程序组件。

The things you want to do should usually be done right after the changes are made, or in the onPause() of the respective app component.

这篇关于安卓:在应用类的onDestroy()或类似的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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