title: Proper way of implementing a periodic action
body: <p>I have the need to send and take something from a server in Android on every 10 seconds. Here, on StackOverflow, and in the documentation I found literally dozens of ways to implement it (and everything I tried does the job), but it seems that everywhere someone says something is wrong with that way.</p>
  
  <p>I tried with a looping <code>AsyncTask</code> until it is canceled (that is untill the activity is killed), and I found out that it's not a good solution. Before that I tried with regular <code>Threads</code>, then I found out that it drains the battery a lot. </p>
  
  <p>Now I've done it with a <code>Runnable</code> and and the ScheduledExecutorService's <code>scheduleAtFixedRate</code> function, similar to the code proposed here:
  <a href="https://stackoverflow.com/questions/6207362/how-to-run-an-async-task-afor-every-x-mins-in-android">How to run an async task for every x mins in android?</a> . Needless to say, it works. But will it work if my Activity is in the background, for example the user is answering an incoming call? </p>
  
  <p>In the end, I don't know anymore what is the most proper way of doing it on an Android phone.</p>
  
  <p>Tnx in advance.</p>