Timing while app in closed

How would I go about making a timing system run while the all is closed in real time, such as how Clash of Clans generates resources while you are away or clicker games have idle bonuses when you log back into the app, for example

Purtroppo le app create con Mit App Inventor, non posso essere eseguite in background.

While your app can’t run in the background, you can cheat.

You can capture the last time your app was running through a TinyDB tag LASTINSTANT and Clock continually storing the current Instant every minute or so.
At startup time, you will have that Instant value waiting for you in TinyDB to compare (clock1.Duration()) against Clock1.Now() to tell you how long it has been since your app ran.
Given that Duration, you can extrapolate what should have happened while you were away from your app, and pretend it all happened.

I actually thought of this, but then though players could cheat by changing their internal clock, but now that I think about it more, that doesnt matter too much anyway for the game im going for.
Thanks a lot for the help!