简体   繁体   中英

Preventing timer manipulation from end user with android TimerTask and Timer

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM