What Is a Foreground Service?
Android Services are background workers. Most are killable at any moment when the system needs memory. A foreground service is special: it must declare a user-facing reason for running, show a persistent notification, and in return gets a strong guarantee that it will not be killed casually.
Foreground services are the backbone of any live experience on Android. They keep location updates flowing for Maps, audio playing for Spotify, the call connected for WhatsApp, and the upload running for Drive.
The Foreground Service Types
Since Android 10 (mandatory in Android 14+) you must declare a type for every foreground service. Each type ties to specific runtime permissions and use cases.
location
Continuous location updates. Requires ACCESS_FINE_LOCATION + FOREGROUND_SERVICE_LOCATION.
mediaPlayback
Audio/video playback. Pairs with MediaStyle notifications.
dataSync
Uploads/downloads/sync. Time-bounded on Android 15. Use WorkManager for periodic.
phoneCall
In-progress voice/video calls (CallStyle).
camera
Continuous camera access from background (e.g. dashcam, video conferencing PIP).
microphone
Continuous microphone (e.g. dictation, voice assistants).
mediaProjection
Screen-recording / casting. User must approve via projection prompt.
health
Workout sessions, continuous heart-rate monitoring (Health Connect related).
remoteMessaging
Long-lived messaging connections (e.g. enterprise IM clients).
shortService
Quick task <= 3 minutes that does not need a typed permission. Auto-stops after the timeout.
systemExempted
Reserved for system / OEM apps with the role.
specialUse
Catch-all for valid cases that do not fit any other type. Requires Play Store justification.
How to Start a Foreground Service
Declare in the manifest
<service android:name=".MyService" android:foregroundServiceType="location|mediaPlayback" /> and add the matching FOREGROUND_SERVICE_* permissions.
Start with the right API
startForegroundService(intent) from an allowed context (typically a user-initiated action). The service must call startForeground(...) within 10 seconds.
Show the ongoing notification
Build a notification with a channel and call startForeground(NOTIF_ID, notification, FOREGROUND_SERVICE_TYPE_*). This is the user-facing surface.
Android 14 + 15 Restrictions to Know
- Android 14: declaring
foregroundServiceTypeis mandatory. The matching runtime permission is required at start time. - Android 14: you cannot start a foreground service from the background unless you fall under one of the documented exemptions (FCM high-priority message, alarm trigger, user-initiated job, etc.).
- Android 15:
dataSyncandmediaProcessingservices are time-bounded; long-running sync belongs in WorkManager. - Android 15:
shortServicecapped at three minutes total; cannot be promoted to a different type. - Android 16: stricter user-engagement rules and richer
ProgressStylenotifications for live progress.
Best Use Cases for Foreground Services
Turn-by-turn navigation
location FGS + MediaStyle/CustomView notification.
Music & podcasts
mediaPlayback FGS + MediaStyle notification.
Voice / video calls
phoneCall FGS + CallStyle notification.
Workouts
health FGS + ongoing notification with stats.
Large downloads / uploads
dataSync FGS (bounded) or WorkManager for unattended work.
Screen recording
mediaProjection FGS + ongoing notification.
iOS Equivalent
iOS does not let apps run general foreground services. Instead, it offers narrow background modes (audio, location, VoIP, BLE central, push to talk) plus the Live Activities framework as the user-facing “something is happening” surface. A Live Activity often does the work an Android FGS + ongoing notification do together.