CraryApplication - detect whether the app goes to the foreground or the background