android.app.Application subclass, onTerminate is not being called
From the documentation for android.app.Application
:
Base class for those who need to maintain global application state.
I am using my own subclass to maintain an object that I'm using to query 开发者_开发百科a server. Also from the documentation:
onTerminate()
Called when the application is stopping.
However, onTerminate()
in my class is never called. I press the back button while viewing my main activity, and everything seems to shut down. My main activity's onDestroy()
method is called and isFinishing()
returns true, but my android.app.Application
's onTerminate()
method is never called.
Why is this? What am I missing? Is there something that is keeping it open?
This might be related to the fact that although you exit the application, the process for it is still running in the background so that restarting the application would use the same process.
Also the javadocs states not to rely on the onTerminate code to be called.
Note: never depend on this method being called; in many cases an unneeded application process will simply be killed by the kernel without executing any application code.
void onTerminate()
This method is for use in emulated process environments.
http://developer.android.com/reference/android/app/Application.html
精彩评论