diff --git a/.idea/other.xml b/.idea/other.xml
index ffb43c5..1b1a2c5 100644
--- a/.idea/other.xml
+++ b/.idea/other.xml
@@ -80,6 +80,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/audio_content/AudioContentPlayService.kt b/app/src/main/java/kr/co/vividnext/sodalive/audio_content/AudioContentPlayService.kt
index 327bc65..a4d382b 100644
--- a/app/src/main/java/kr/co/vividnext/sodalive/audio_content/AudioContentPlayService.kt
+++ b/app/src/main/java/kr/co/vividnext/sodalive/audio_content/AudioContentPlayService.kt
@@ -6,10 +6,10 @@ import android.app.PendingIntent
import android.app.Service
import android.content.Context
import android.content.Intent
+import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.media.AudioAttributes
-import android.media.AudioManager
import android.media.MediaPlayer
import android.os.Build
import android.os.Handler
@@ -511,7 +511,16 @@ class AudioContentPlayService :
.setShowActionsInCompactView(0, 1)
)
- startForeground(1, notificationBuilder.build())
+ val notification = notificationBuilder.build()
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ startForeground(
+ 1,
+ notification,
+ FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
+ )
+ } else {
+ startForeground(1, notification)
+ }
}
override fun onLoadCleared(placeholder: Drawable?) {
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/common/SodaLiveService.kt b/app/src/main/java/kr/co/vividnext/sodalive/common/SodaLiveService.kt
index d3b41a1..635ae50 100644
--- a/app/src/main/java/kr/co/vividnext/sodalive/common/SodaLiveService.kt
+++ b/app/src/main/java/kr/co/vividnext/sodalive/common/SodaLiveService.kt
@@ -7,6 +7,8 @@ import android.app.PendingIntent
import android.app.Service
import android.content.Context
import android.content.Intent
+import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
+import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
import android.os.Build
import android.os.IBinder
import androidx.core.app.NotificationCompat
@@ -33,7 +35,19 @@ class SodaLiveService : Service() {
}
private fun updateNotification(content: String) {
- startForeground(Constants.LIVE_SERVICE_NOTIFICATION_ID, createNotification(content))
+ val notification = createNotification(content)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ val foregroundServiceTypes = FOREGROUND_SERVICE_TYPE_MICROPHONE or
+ FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
+
+ startForeground(
+ Constants.LIVE_SERVICE_NOTIFICATION_ID,
+ notification,
+ foregroundServiceTypes
+ )
+ } else {
+ startForeground(Constants.LIVE_SERVICE_NOTIFICATION_ID, notification)
+ }
}
private fun createNotification(content: String): Notification {