Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.app.Application subclass, onTerminate is not being called

Tags:

android

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?

like image 907
synic Avatar asked Mar 19 '10 23:03

synic


1 Answers

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.

like image 135
Moritz Avatar answered Sep 23 '22 02:09

Moritz