Android does not provide a native way to be notified of applications starting and stopping. This project solves that problem.
For reference, the project includes a working example Android application composed of two Activities.
ApplicationSessionActivityinto your project.
- Add the
android.permission.GET_TASKSpermission to your
- Make all of the Activities defined in your project extend
- Create an
ApplicationSessionActivity.SessionStoppedListener, and place the code you want to be run at app start and stop into their listener methods.