Service architecture, continuously running vs. wake up
<p>I have an application that wakes up at frequent intervals (once per minute) to do some stuff in the background.  I will be using the <code>AlarmManager</code> to schedule the wake ups.</p>

<p>I am looking at two different ways of structuring a <code>Service</code> to do the background work:</p>

<ol>
<li>keep the service continuously running in the foreground with <code>setForeground()</code>.  This is attractive since the application state will remain in memory between wake-ups.</li>
<li>use <code>stopSelf()</code> to destroy the <code>Service</code> after it has finished running the background task.  This will require persisting some non-trivial objects between each wake up.</li>
</ol>

<p>What are the pros and cons of each approach?  How costly is persistence?  What is the recommended approach for storage for case 2?</p>
