apptentive/ApplicationSessionActivity
Android does not provide a native way to be notified of applications starting and stopping. This project solves that problem. Make your Activities inherit from ApplicationSessionActivity, and you can run code when the app starts and stops.
JavaMIT