Perform background scheduled repeating task in Android, and differences between IntentService and Runnable
<p>I am an iOS developer and recently started Android development. Currently I need the application to perform a repeating check regarding a remote resource (a JSON file) in the background, which I would like to:</p>

<ol>
<li>App finished launching</li>
<li>Initiate scheduled repeating task in Application subclass</li>
<li>Application will be noticed if there are any changes in the remote JSON file and handle it accordingly</li>
</ol>

<p>After doing some research I found that there seems to have many ways to achieve this, while I can rule out some of them, I can't really tell the differences between the rest and which I should use.</p>

<p>I've found that to perform a scheduled repeating task, I can use the following classes:</p>

<ol>
<li><code>ScheduledThreadPoolExecutor</code></li>
<li><code>IntentService</code></li>
<li><code>AlarmManager</code></li>
<li><code>Runnable</code> (with <code>postInBackgroundDelayed</code> / <code>DelayedRunnable</code>, or maybe <code>ScheduledExecutorService</code>?)</li>
</ol>

<p>And I've ruled out the use of:</p>

<ol>
<li><code>ScheduledThreadPoolExecutor</code>, I've read that this is best used when multiple worker threads are needed, which in my case I only need one</li>
<li><code>AlarmManager</code>, this will be executed even when the app is not running, while I only need the task to be performed when the app is running</li>
</ol>

<p>And for the rest, which are <code>IntentService</code> and <code>Runnable</code>, from my understanding so far:</p>

<ol>
<li><code>IntentService</code>, needed to be started and stopped manually, tasks are invoked by sending an Intent to the service, and then the result is broadcasted</li>
<li><code>Runnable</code>, like the block used in Objective-C, a specific segment of code to be executed at appropriate time</li>
</ol>

<p>Other than these are there any other differences between them? Is my understanding correct? Are them both appropriate for my task? It it is the case, are there any considerations before choosing which one to use?</p>

<p>Thanks!</p>