Issue with app not changing value of variable when display is OFF

I created a timer app that changes time with delay. But when the display is off, or the app is minimised, the timer pauses.
The logic of the timer:

Is there a way I can make the variable change value when the display is off?

I think this is already a feature request: Ability to run a timer while screen is off | Voters | AppGyver Community Edition

I am assuming on timeout the cache is cleared on your device.

You could try storing the time to the device and see if this persists (video below).


Another thing you could try, though more complicated, is to use the device time and format it, and then calculate based on that. For example get the device time for a 60 second timer, continue to get it every second or so and update accordingly. Then when the screen comes back on > would assume it continues to pull the system time, but I could be wrong, I am also assuming you can pull seconds from system time but havent tried.

Forum on system time: How to get the device time?

I tried device storage, that didnt work, it stops updating when the display is off. I will try to pull time from system, if that’s possible.
Thank You