1

How can one ensure that a task that is supposed to run for x amount of time on an android os be run for that x period without user manipulation of date and time? For example, if I want this timer to run for 24 hours solid and then advise the user that 24h has passed, even if the phone is off for an hour, the user then turns it back on and sets the system time forward 2 hours, this timer would still indicate when that solid 24 hour period had passed without the user manipulating the system date/time and without connecting to the internet to verify the proper amount of time has passed.

Thanks

Euthyphro
  • 700
  • 1
  • 9
  • 26

1 Answers1

0

Here is flow/algorithm.

1) You need to store time of timer first initiated some where, probably database and let timer run for 24 hours.
    a) assuming phone not turned off, timer continues
    b) Assuming phone turned off and turned on
        b1) Get initial timer started time from database, then calculate how much time left for 24 hours. 
        b2) Initiate timer again with left time.
kosa
  • 65,990
  • 13
  • 130
  • 167
  • Thanks, your suggestions in addition to what I read in the following link should suffice. http://stackoverflow.com/questions/6328052/how-to-prevent-usage-of-expired-license-through-system-clock-tampering should su – Euthyphro Dec 05 '12 at 05:04
  • @Euthyphro: Your question text gives completely different information. Anyway if that link helped, I would suggest deleting this question. – kosa Dec 05 '12 at 05:06
  • I think the concept is similar. Essentially there is no true way to prevent user manipulation of the system time in a way that could affect a running application if the app doesn't check with an external source. If I have a game that requires a predefined skill that trains over 2 days, if the user wanted to cheat they could modify the system clock. I could always have the app check the system clock to ensure it doesn't suddenly change or jump days ahead or back, however, the user could also always kill the app and then there goes that approach. – Euthyphro Dec 05 '12 at 05:13