I want to calculate time difference between the last event on the device and the current. But the user can always change the time manually by setting the system time, so the difference can be different from the real time. Is there a way to calculate time difference that is correct?
Share
You can use
System.nanoTime()between the two periods, then subtract. UnlikeSystem.currentTimeMillis()which changes when the user changes the device time,System.nanoTime()will not be affected.