From 2af894eb9a472d07cb7442daff4d44bfef937332 Mon Sep 17 00:00:00 2001 From: Kenny Daniel Date: Thu, 8 Aug 2024 23:22:31 -0700 Subject: [PATCH] Fix foreground service location type --- app/src/main/AndroidManifest.xml | 2 ++ .../java/com/platypii/baseline/ForegroundService.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ffa3bb46..b0569c03 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,9 @@ + + diff --git a/app/src/main/java/com/platypii/baseline/ForegroundService.java b/app/src/main/java/com/platypii/baseline/ForegroundService.java index 85aa5176..d1652bc0 100644 --- a/app/src/main/java/com/platypii/baseline/ForegroundService.java +++ b/app/src/main/java/com/platypii/baseline/ForegroundService.java @@ -3,6 +3,8 @@ import android.app.Notification; import android.app.Service; import android.content.Intent; +import android.content.pm.ServiceInfo; +import android.os.Build; import android.os.IBinder; import android.util.Log; import androidx.annotation.Nullable; @@ -58,7 +60,11 @@ private void updateNotification() { // Show notification Log.i(TAG, "Showing notification"); final Notification notification = Notifications.getNotification(this, logging, audible); - startForeground(Notifications.notificationId, notification); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + startForeground(Notifications.notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION); + } else { + startForeground(Notifications.notificationId, notification); + } } else { // Stop service Log.i(TAG, "Stopping foreground service");