Service and foreground notifications

3242
0

Services run background operations without UI. I extend Service and override onStartCommand() for started services or onBind() for bound services. Foreground services use startForeground() with ongoing notification, required for long-running tasks visible to users. START_STICKY restarts service after system kills it. IntentService handles async work on worker threads automatically. Bound services enable client-server IPC with Binder. JobIntentService replaces IntentService for API 26+. Services require manifest declaration and runtime permissions. WorkManager or foreground services replaced many background service use cases. Foreground services ensure critical operations—music playback, navigation, file uploads—aren't killed, while keeping users informed.