Android Tutorial #12: Foreground Services — Music Player, Location Tracking

Your music app needs to keep playing when the user switches to another app. Your fitness app needs to track location while the phone is in the user’s pocket. A download manager needs to stay alive until the file is complete. These are foreground services. They run long-running operations that the user is aware of, shown with a persistent notification. In this tutorial, you will learn how to build foreground services — service types, lifecycle, communication with the UI, and practical examples for music playback and location tracking. ...

July 7, 2026 · 10 min