diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/tts/TtsService.java b/app/src/main/java/fr/gaulupeau/apps/Poche/tts/TtsService.java index e7a7f2d78..3b0d95247 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/tts/TtsService.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/tts/TtsService.java @@ -10,10 +10,12 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; +import android.content.pm.ServiceInfo; import android.graphics.Bitmap; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.Binder; +import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.os.SystemClock; @@ -1138,7 +1140,11 @@ private void setForegroundAndNotification(boolean forceForeground) { if (foreground) { if (!isForeground) { Log.v(TAG, "setForegroundAndNotification() startForeground()"); - startForeground(NOTIFICATION_ID, generateNotification()); + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.TIRAMISU) { + startForeground(NOTIFICATION_ID, generateNotification()); + } else { + startForeground(NOTIFICATION_ID, generateNotification(), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK); + } isForeground = true; } } else {