I would like to know how to execute code before exiting application. My application is composed of several activities. When the user starts the application (from the launcher menu or from a notification in the status bar), he goes in an InitActivity where I process some initializations. From user experience, application always restarts.
One of these initializations is to init a network manager and start a thread that periodically sends a network request to notify a server that application is active. I need to process some end operations, like stopping this thread when user quits application, for example by pressing the HOME key or BACK key when he's in the root activity. However, when the user press the HOME key, application is still running in background. Here are my questions : Q1 : is it possible to execute code when exiting application (I see the onTerminate() method of the class Application but it seems not to be always called) ? Q2 : Is it possible to force application exit (activity method finish () only destroy the current activity, not the application) ? Q3 : Is it possible to handle HOME key press (onKeyDown() is not called when this button is pushed) ? Thanks for your help. -- 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