포그라운드 서비스 시작시 foregroundServiceTypes 추가
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user