I am not sure what you are trying to do, but most people that want something like what you are describing are usually interested in keeping some kind of simulation going, even when the game is closed.
Games that do this keep track of the last known time they were active and then look at the new current time when the game becomes active again, with both numbers they calculate the difference.
With that difference the game then simulates all the things that would have happened in that time, should it have been active.
This is the correct way to approach the problem, because you can never know what the OS will decide is better for your application. This is particularly true for mobile devices where the OS will aggressively try to save battery power, and in most cases that means stopping any process which is deemed not useful, such as applications that are in the background and not being interacted with.