I have an app that shall be extended with an app tracking code that should track the following events: app started, closed, foreground and background. My application has two activities.
For app started i use app.onCreate(). For foreground and background: onResume and onPause in each activity.
So my questsions are:
- How do i detect when the application is completely gone? Something like onTerminate()?
- When switching from the first activity to the second, i get a1.onPause() and then a2.onResume() and thus the events background followed by foreground. In that case i don't want those events. How do i know in onPause or onStop that i am staying in my app and only switching activities?
What i want is: App starts with a1 -> app started and app foreground event then switch to a2 -> nothing, press home -> background. When the app gets killed -> closed
At least i think i want that, or should one not use such a linear approach because of androids specific application and activity lifecycle and do something else?