The api im calling requires that i send a unix timestamp in seconds in order to get the changes that occurred to an entity since that time.
i can't use currentTimeMillis
because that can be changed by user, and i cant use elapsedRealtime()
is device dependent
is there away to get this time?
source: https://developer.android.com/reference/android/os/SystemClock
Asked
Active
Viewed 115 times
0

AmSabba
- 67
- 5
-
Use an SNTP library to call a time server. – CommonsWare Apr 05 '20 at 17:28
-
you can look at this answer, please :https://stackoverflow.com/a/54405264/10797722 – Ade Dyas Apr 05 '20 at 17:38
1 Answers
1
You can create a repository that fetches the Unix time from a server, like this one
http://worldclockapi.com/api/json/utc/now
The only concern is that you need internet permission.

Francesc
- 25,014
- 10
- 66
- 84