java - Android: time intervals with deep sleep (System.nanoTime(), System.currentTimeMillis(), SystemClock.elapsedRealtimeNanos()) -
I am implementing an application in which the minimum API level is 14 (this is important) and it is used to measure frequent interval the wanted. There is no need for MS precision, it should always calculate the time (spent seconds).
So far, for the treatment of time intervals, I knew these solutions:
-
System.nanoTime () - If Android is running It works so well, but closes on deep sleep (it is bad).
System.currentTimeMillis () - Good, but not fair because it's by user or code by
SetCurrentTimeMillis (long) .
SystemClock.elapsedReautimeNanos () - Time has passed on deep sleep, but API level 17 is required.
is there any other way of measuring an appropriate second precision interval to measure on API 14?
I used to think about usingSystem.currentTimeMillis () to listen to the broadcast clock or not that the system clock has changed. Although this does not seem to be the best solution.
Have you tried?
Comments
Post a Comment