Faced such a problem: it is necessary to catch the launch and close of my application. At startup, a thread should be created (well, I have no problems with this), and when stopped method should be called once.
onCreate with start - created a class successor ( Application ), in onCreate appointed start of a flow. And with the closure of the application, I was stumped. The fact is that my application contains a lot of activations that open during the application, so in each onStop not an option to call stopped , and the Application cannot override the onStop method (since it does not exist).
The question is: "Is it possible to catch the complete closure of the application (and not a certain activation) and how?".