the game on Android , let's say there is a certain method, it must be activated from a certain date, say today 02.02.2018 , the method does not work in the game, and starting from 05.02.2018 method will be executed when the player enters the game, I beg you to explain how and in what ways it is possible to implement.

  • one
    There are many ways. You can insert and interrupt its execution at the beginning of the date check method if the date is not appropriate. You can embed the scheduler in the application and pass on to it the execution of certain actions on the calendar of events. In general, there are options, but you need to understand why it is necessary to advise something concrete. - rdorn

1 answer 1

In C #, there is a DateTime structure that is responsible for the date and time. This structure has a DateTime.TryParse method (string, out DateTime) that tries to turn the passed string into a DateTime instance, and the DateTime.Now field returns the current date and time value. Application examples are at the bottom of the msdn article to which I gave a link.

Those. The sequence of actions is approximately as
- You record somewhere in your settings the date and time in the international standard (also in the article) as a string.
- When calling a method, turn this string into a DateTime structure using TryParse.
- Compare the current value obtained from DateTime.Now with yours and either execute the method or not.
However, it is worth remembering that such a test can be bypassed simply by changing the time on the device. As an option - to get time from the Internet by third-party methods (if you use any plug-ins from Internet services, for example, advertising, there may well be a similar opportunity), and if the Internet is not available, the method is also not available.