Event to detect app going into background?

Hi I am trying to create a quiz app that has this private variable remaining_time that is initially set to the number of seconds allowed to take the test and then in delay of 1 second I keep subtracting the seconds and updating the variable. Then I have this check with every subtraction to see if its 0 to end the test. This all works perfectly fine. However when I switch the app with other apps and then resume the app the timer/delay function stops executing. Is there any way to prevent this like keep running in background, Secondly is there any event that I can use to identify if the user resumed the app so that I can calculate and reassign the number of seconds left.

1 Like