How to calculate time elapsed since an action without the danger of the user changes the time
Hi i am developing an application and i want the user to be able to kill an enemy again after 12 hours have passed. How can i do this to avoid the possi开发者_如何学Cbility of the user changing the time in his phone and enabling again the option to kill an enemy?
Use a sticky service. Every time you kill an enemy, run a CountdownTimer.
However I think this is overkill, If it is a simple game that you are making, you should store the elapsed time since boot. Then regenerate the enemy if the time difference is > 12 hours.
精彩评论