我怎样才能做一个Android应用程序之前进行一些清理权利退出? [英] How can I do some cleanup right before an Android app is quitting?

查看:92
本文介绍了我怎样才能做一个Android应用程序之前进行一些清理权利退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有某种onTerminate()方法,在那里我可以做一些清理(我想清楚了一些共享preferences)时,我的Andr​​oid应用程序将终止?

Is there some sort of onTerminate() method where I can do some cleanup (I want to clear some SharedPreferences) when my Android app is terminating?

我有一个保持几个数字的平均运行的活动,那我存储在共享preference。我希望在应用程序运行(用户可以在不同的活动之间移动),这个平均到最后,所以我不能清除它的onDestroy()为特定的活动。我需要能够将其清除,一旦应用程序即将退出。

I have an Activity that is keeping a running average of a few numbers, that I'm storing in a SharedPreference. I want this average to last while the app is running (the user can move between different activities) so I can't clear it on onDestroy() for that particular activity. I need to be able to clear it once the app is about to quit.

我怎样才能做到这一点?

How can I do this?

推荐答案

因此​​Android并没有真正有一个应用程序的概念被汉化。 Unfortunently没有什么同义于onTerminate()。有一些标准,通过它可以决定何时清除您的移动平均值?

So android doesn't really have a concept of an app being "finished". Unfortunently there is nothing synonymous to "onTerminate()". Is there some criteria by which you can decide when to clear your running average?

这篇关于我怎样才能做一个Android应用程序之前进行一些清理权利退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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