Well, I've never expected onTerminate to be useful, but subclassing Application is.
The Application's onCreate() method (and any static and instance initializers) are called before ANY application component is created or loaded. There's no other way to make this guaranty that I am aware of. You can come close if you put a reference to a singleton in every single component, and remember to always do so. But that's not a good approach -- it violates once-and-only-once. And if you're using third- party code as part of your app, it may not be possible. Although, admittedly, such code reuse is rare and problematic on Android, so it's nearly always possible. But why campaign against Application? It's a perfectly fine singleton itself, it's just misunderstood. Fix the documentation. Deprecate onTerminate. Suggest to people that their modularity would benefit if they group related statics into their own singleton, and their memory use might even improve if they then reference this singleton only where it's needed. On Oct 31, 3:39 pm, Dianne Hackborn <hack...@android.com> wrote: > It is just totally wrong to rely on onTerminate. There is just > fundamentally no reason to worry about "cleaning up your statics" when the > way your process goes away is by killing it. There isn't anything to clean > up. And anyway, onTerminate never gets called. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en