有某种onTerminate()方法,在那里我可以做一些清理(我想清楚了一些共享preferences)时,我的Android应用程序将终止?
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?