The App has a Timer() which needs to continue once the Home button is pressed.
I suggest a different approach: log the time the Timer started and simply recreate the Timer in onResume()
. This way you don't have to worry about the app being killed, running the Timer in a service, etc. If you want a task to be run while the app is paused, setup a AlarmManager event in onPause()
.
I override the Back button to Minimise the app if the Timer() is on, is there a way to do this with the Home button?
To address this specifically, you can use onUserLeaveHint()
or the generalized onPause()
.