Skip to content

landomen/ForegroundServiceSamples

Repository files navigation

Android 16 - Foreground Services Sample

This sample app demonstrates how to use the foreground service on Android 16. It is meant as a companion to the Guide to Foreground Services on Android 14 blog post and Guide to Foreground Services on Android talk at AppDevCon 2025 and droidcon Berlin 2024.

It shows two approaches on how to create and start a foreground service:

  1. The standard way of creating a standard Service and promoting it to a foreground service.
  2. The new way of using a long-running worker using WorkManager that runs as a foreground service under the hood.

Included are the following functionalities:

  • Starting a foreground service with a declared foreground service type of location
  • Requesting location permissions before service is started
  • Binding to the foreground service from Activity to display the service status and receive location updates
  • Stopping the service from the activity
  • Requesting notification permission to show foreground service notification
  • Using WorkManager to run a long-running foreground service task

Previews

References

About

Simple sample app demostrating how to use Foreground Services on Android 16.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages