title: Android: time intervals with deep sleep (System.nanoTime(), System.currentTimeMillis(), SystemClock.elapsedRealtimeNanos())
body: <p>I am implementing an application that has a minimum API level 14 (this is important) and requires consistent interval measuring. No need for ms precision, it just needs to be always counting the time (elapsed seconds).
  <br><br>
  So far, to treat time intervals, I knew these solutions:</p>
  
  <ol>
  <li><code>System.nanoTime()</code> - Works great if Android is running, but stops on deep sleep (this is bad).</li>
  <li><code>System.currentTimeMillis()</code> - Good, but not appropriate because it can be changed by the user or by code with <code>setCurrentTimeMillis(long)</code>.</li>
  <li><code>SystemClock.elapsedRealtimeNanos()</code> - Counts elapsed time even on deep sleep, but requires API level 17.</li>
  </ol>
  
  <p>Is there another way to get a reasonable second-precision interval measuring on API 14? <br>I thought about using <code>System.currentTimeMillis()</code> listening to the broadcast intents to see if the system clock has changed. However this does not seem to be the best solution.</p>