mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
chore: Adapt to new foreground service
This commit is contained in:
parent
f80d3cbe16
commit
cb43a1b371
@ -5,10 +5,13 @@ import android.app.Notification
|
|||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.ServiceInfo
|
||||||
import android.os.Binder
|
import android.os.Binder
|
||||||
|
import android.os.Build
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
|
import androidx.core.app.ServiceCompat
|
||||||
import app.myzel394.alibi.MainActivity
|
import app.myzel394.alibi.MainActivity
|
||||||
import app.myzel394.alibi.NotificationHelper
|
import app.myzel394.alibi.NotificationHelper
|
||||||
import app.myzel394.alibi.R
|
import app.myzel394.alibi.R
|
||||||
@ -150,7 +153,16 @@ abstract class RecorderService : Service() {
|
|||||||
recordingStart = LocalDateTime.now()
|
recordingStart = LocalDateTime.now()
|
||||||
|
|
||||||
val notification = getNotificationHelper().buildStartingNotification()
|
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
|
// Start
|
||||||
changeState(RecorderState.RECORDING)
|
changeState(RecorderState.RECORDING)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user