I'm new to Java
and Android
and I'm coming from a Qt/C++
background. In Qt
there is this QCoreApplication
object that represents the whole application and when this object is destroyed, the application dies. In Qt
there is this signal on QCoreApplication
which is QCoreApplication::aboutToQuit
which gets emitted when the application is in an imminent process of being closed. This is very handy when you want, e.g. save settings data to disk just before the application is closed.
My question: Is there a similar aboutToQuit
-like mechanism with which you could get notified when an Android application is imminently closing?
EDIT:
I would like to make some additions to my question after nPn answer. We cannot rely on the Android Activity Life Cycle as we need this information in a library/SDK we are developing. So we want to get notified when an application that is using our library/SDK is closing.
We are developing an SDK
for some clients to use in Android
apps. Like this would not be enough, this SDK
also uses a native C++ SDK
in the background with which is linked with through a JNI
interface.
The end goal is to get notified in C++ that the application is being destroyed in Android. Having an event/signal in Android would be enough as we could forward the information to C++.
So as a resume the layers are: Android App -> Custom Android SDK -> Native C++ SDK
If there is something unclear, I will edit the question further