Skip to content

Commit

Permalink
chore: Adapt to new foreground service
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Oct 24, 2023
1 parent f80d3cb commit cb43a1b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/src/main/java/app/myzel394/alibi/services/RecorderService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import android.app.Notification
import android.app.PendingIntent
import android.app.Service
import android.content.Intent
import android.content.pm.ServiceInfo
import android.os.Binder
import android.os.Build
import android.os.IBinder
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.ServiceCompat
import app.myzel394.alibi.MainActivity
import app.myzel394.alibi.NotificationHelper
import app.myzel394.alibi.R
Expand Down Expand Up @@ -150,7 +153,16 @@ abstract class RecorderService : Service() {
recordingStart = LocalDateTime.now()

val notification = getNotificationHelper().buildStartingNotification()
startForeground(NotificationHelper.RECORDER_CHANNEL_NOTIFICATION_ID, notification)
ServiceCompat.startForeground(
this,
NotificationHelper.RECORDER_CHANNEL_NOTIFICATION_ID,
notification,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
} else {
0
},
)

// Start
changeState(RecorderState.RECORDING)
Expand Down

0 comments on commit cb43a1b

Please sign in to comment.