How to create Energy/Lives that regen in realtime on mobile devices?

I want to create one of those systems on an android device where, losing a level takes away one life point, but you have to wait, say an hour, to get another life point, and you can’t play if you have no lives.

The idea I’ve thought of is to, when the player opens the level select, check the time difference from the last time they opened the level select, and then calculate how much time has passed and go from there, dividing the time by the length, refilling, etc.

Although this seems simple and easy, is there any other ways to do this?

EDIT: To be more clear on what it is I am trying to do, I want an energy system similar to Dots, CandyCrush, BestFiends and other similar games.

Every 15 minutes the player will regen one more energy point. There is a timer visible in the UI ticking down til their next regain. If they were to close the app for two minutes, then return, two minutes should have passed on the in game timer as well. And if they are gone for an hour, when they come back, they will have four energy points and the timer is again counting down to the next regain point.

The timer has to appear to be constantly ticking when the app is not running, so they can always open it up and see that every second that has passed in the real world as passed in the game.

I would probably store a list of active start times for each timer and then you can find out where their appropriate end time should be by adding to start time and comparing that against the current time. If the timer still needs to run then you can update it in tick as it counts down towards the end time.

This makes sense, except for there being multiple timers. Is each timer for each interval of energy regain?

Well not knowing a whole lot about how your game works I used the standard social game template in my thinking which has energy and build/craft times for various things that are happening.

What I was thinking instead of checking based on what time you open/close things then check vs the last time you gave the player energy/lives. If you gave them a life every 5 mins then it shouldnt matter if they are in the level select or not was my line of thinking that you want to award them that in realtime as you suggested.

Perhaps you can give some more details on what youre trying to achieve as an end result rather than your method of getting there.

Okay, I’ve added more information.
And, not to be rude, but your lack of punctuation also makes it hard to understand.

Here I was thinking you dont start a sentence with and! Good luck!

I’m not surprised you think that, considering you have poor grammar in the first place.

Fact of the matter is, starting sentences with conjunctions are more than just allowed and can be found used in the best pieces of writings. It adds a dynamic flow to the writing causing it to “bump” up and grab their attention. They only teach it to be wrong in school because little kids tend to misuse/overuse it.

And, if you don’t believe me, feel free to look into it. Considering your level, right about here is a good place to start.

And, you might actually learn that you’re supposed to put quotes around your “and” when you reference it like you did!

Cheers!