Handling the pause/resume and backbuttons events