Is there any known problem with using time(NULL)
on Android?
I tried running the following piece of code:
int32_t now1 = time(NULL);
int64_t now1_6 = (int64_t)time(NULL);
int32_t nt = (time_t)-1;
int64_t nt6 = (int64_t)-1;
And then log the result using the following format:
"Now1 is %d. Now1_6 is %lld. NT is %d. NT6 is %lld.\n", now1, now1_6, nt, nt6
This is the output I got:
01-05 19:10:15.354: I/SMOS(11738): Now1 is 1533390320. Now1_6 is 6585861276402981128. NT is 0. NT6 is 283493768396.
There were other problems as well, such as getting the same time values on different loop iterations.
I encountered these issues on both a virtual and a physical device running Android 4.0.3 (API 15), both of which were configured with the correct time. The output above is from the physical device.
I am led to believe there is a problem with this particular POSIX function in Bionic, but I could not find any reference to such, either online or in the Bionic docs.