Foreground Service

When the Sentiance SDK runs in the background, it starts a foreground service to maintain reliable detections. This is a requirement enforced by Android to ensure long-running background processing can continue even when the app is not in focus.

Foreground Service Notifications

Starting a foreground service requires showing a persistent notification. This is mandated by the Android OS to inform users about ongoing background work.

By default, the SDK displays a minimal notification using the app’s name and icon. However, you can fully customize this notification to match your app’s branding and use case.

To customize the notification, create a notification object and set it on the SDK initialization options. At runtime, you can update this notification by calling updateSdkNotification.

Foreground Service Types

In compliance with Android 14 (API level 34) and higher, foreground services must declare a specific service type in the manifest. The Sentiance SDK declares the following service types in its Android Manifest:

  • location: indicates that the service is accessing location data in the background.

  • shortService: indicates that the service is expected to run short tasks.

Last updated