title: Foreground service vs WorkManager for location tracking
body: <p>Let's say I want to build an app which requests current location periodically (e.g., every 10 minutes, this number should be configurable) and submits to a server.</p>
  <p>I'm aware that Foreground Service and WorkManager are normally suggested for this kind of scenario. However which is would suit more? Below are my thoughts and doubts.</p>
  <ol>
  <li><p>WorkManager - is mainly for deferrable background work whose execution is guaranteed. However I know that from Android 8 (API 26) background location was introduced and that restrict location to be updated only a few times every hour <a href="https://developer.android.com/about/versions/oreo/background-location-limits" rel="noreferrer">https://developer.android.com/about/versions/oreo/background-location-limits</a>. Thus this perhaps doesn't meet the periodical updates as per the requirement.</p>
  </li>
  <li><p>ForegroundService - is perfect for something that runs and needs to make users aware of. It's recommended for this kinda scenario (location tracking) for privacy purpose. Google also creates a sample app to promote this practice <a href="https://github.com/android/location-samples/tree/master/LocationUpdatesForegroundService" rel="noreferrer">https://github.com/android/location-samples/tree/master/LocationUpdatesForegroundService</a>.</p>
  </li>
  </ol>
  <p>From the above analysis, it seems <code>ForegroundService</code> is the one. However I also found that <code>WorkManager</code> has a built-in support to use Worker in conjunction with <code>ForegroundService</code> via <code>androidx.work.impl.foreground.SystemForegroundService</code> <a href="https://developer.android.com/topic/libraries/architecture/workmanager/advanced/long-running#long-running-kotlin" rel="noreferrer">https://developer.android.com/topic/libraries/architecture/workmanager/advanced/long-running#long-running-kotlin</a></p>
  <p>That makes me confused as to what should I use and what Google really recommend for this specific scenario.</p>
  <p>Anyone has any idea?</p>