Simple code to add to any Android application to detect its going to the background, or it is coming back to the foreground.