Clickergame like Money system, how to get money based on time when not ingame?

Ola,

so i would know how to make a simple get X money at X time under X circumstances.

The question for me now is, how would still work when the app is closed ?
Do i have to get the android time before closing, calculate the time where the player wasnt ingame and adding X values to the currency when back online?
Or is there a even easier way to archieve this ?

Thx

It can only work by using a server where you can store user status + time.
If you use the time of the phone, users can manipulate it by simply changing the time on their device.