I can get the time change events with the help of broadcast events (ACTION_TIME_CHANGED
and ACTION_DATE_CHANGED
).
I need to get the previous time after time change. For example, the current time is 10:00. I am going to change time to 12:00. After time change, time will be changed to 12:00, but I need to get the previous time (10:00) at the time of time change.
Note: Time can be changed from any other app or from settings.
Maybe the solution I found can help you:
(Is there a way to detect when the user has changed the clock time on their device?)
The above solution could work setting a static variable on BOOT of device with System.currentTimeMillis()
, and sum with SystemClock.elapsedRealtime()
. With this sum you have the before time.
But there is a problem (I don't know if it matters to you), if the user does not reboot the device, then your diff will be == 0
and you will not be able to have this diff between old and actual System.currentTimeMillis()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With