title: Where is the best place to schedule AlarmManager to do a periodic background data sync?
body: <p>My Android application will be periodically polling a server to check for data.  I want this polling to happen regardless of user interaction with the application, similar (in concept) to how the Gmail and Google Reader apps sync data in the background.  Once the app is installed, these periodic syncs should begin happening.  I do <strong>not</strong> think that scheduling the alarm from inside an <code>Activity</code> is the way to go, because I do not want to wait for the user to open my application.  </p>
  
  <p><strong>What is the best practice in this case for placing the call to</strong> <code>AlarmManager.setInexactRepeating</code>?</p>
  
  <p>Some possibilities I could think of are:</p>
  
  <ul>
  <li>Extend <code>Application</code> and do it in <code>onCreate</code></li>
  <li>Do the scheduling from within a <code>Service</code> that is set to <code>android:enabled=true</code> within the manifest.</li>
  <li>Listen for some particular broadcast message(s), and schedule from within a receiver</li>
  </ul>