Trying to make a manual date change log. I set up a BroadcastReceiver for the android.intent.action.TIME_SET event. Everything is as it should be - I’m catching the events of changing the date and time, writing down the date I set in the log. Everything is OK, but there is a problem, you need to write down the date before the change. Is it possible to find out also the date before the change?

Logging should be done when the "flight mode" is on. Only a service that constantly monitors the current time came to mind, but this solution does not seem to be correct.

    1 answer 1

    There is such a thing SystemClock.elapsedRealtime() - the time since the device was loaded. Register a boot receiver, calculate the difference in it with System.currentTimeMillis() and save it somewhere. When intercepting action.TIME_SET again consider this difference and compare it with the saved one. Well, there it should already be clear where and how much time was transferred.

    • Thank you, everything is very simple and works well. - Sergey Alexandrov