Android Question Time Keeping When App Isn't Running(SOLVED)

Stichler

Active Member
Licensed User
Hello all,

I'm writing a Pet game for my kids and I need to be able to have things be monitored even when the kids are not using the app. Things like the pets hunger level and maybe even have a notification sent to the phone when pet is hungry. Can someone steer me n the right direction to find out how to do what I need?

Thanks.
 

npsonic

Active Member
Licensed User
You could just create one file that contain millis from everything you want to track and one timer that reads the file for example in 1 minute intervals.
If Datetime.Now is more than you have set into file then you can take proper action and update new millis into file.
 
Last edited:
Upvote 0

npsonic

Active Member
Licensed User
Ok but what about when the kids close the app will this still run?
You can declare timer from Starter service, so it shouldn't get killed. It only matters if you want to create notifications from background.
When everything is stored to the file you can easily read the file next time when app is opened and calculate how much time has passed from last actions.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…