title: Scheduling Repeating Tasks in a Service
body: <p>I need to repeat a task every 1 hour in the background (I am sending some info to my server).</p>
  
  <ol>
  <li><p>I tried to use a service with a post delay handler calling it self.</p>
  
  <pre><code>   handler = new Handler(); 
  runable = new Runnable() { 
  
      @Override 
      public void run() { 
          try{
  
          //sending info to server....
  
          }
          catch (Exception e) {
              // TODO: handle exception
          }
          finally{
              //also call the same runnable 
              handler.postDelayed(this, 1000*60*60); 
          }
      } 
  }; 
  handler.postDelayed(runable, 1000*60*60); 
  </code></pre></li>
  </ol>
  
  <p>This did not work, in small time interval of 1 minutes it worked fine, when i changed it to 5 minutes it worked for about 5 repetitions and then the timing got wrong and after an hour the service shut down.</p>
  
  <ol start="2">
  <li><p>i want to try to use a AlarmManager but in the <a href="https://developer.android.com/training/scheduling/alarms.html" rel="noreferrer">documentation</a>
  it says "As of Android 4.4 (API Level 19), all repeating alarms are inexact" 
  does anybody know how inexact it is? is it seconds? ,minutes? 
  can i rely on this to work on time?</p></li>
  <li><p>does anybody have any other suggestions for repeating tasks in a service?</p></li>
  </ol>
  
  <p>Thanks</p>