Simplify access to platform's `getSystemService` with reified Androidx's version

pull/1898/head
Simon Marquis 2 months ago
parent 401e784216
commit 360e103295

@ -22,6 +22,7 @@ import android.app.NotificationManager
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.content.getSystemService
import androidx.work.Constraints import androidx.work.Constraints
import androidx.work.ForegroundInfo import androidx.work.ForegroundInfo
import androidx.work.NetworkType import androidx.work.NetworkType
@ -60,10 +61,7 @@ private fun Context.syncWorkNotification(): Notification {
description = getString(R.string.sync_work_notification_channel_description) description = getString(R.string.sync_work_notification_channel_description)
} }
// Register the channel with the system // Register the channel with the system
val notificationManager: NotificationManager? = getSystemService<NotificationManager>()?.createNotificationChannel(channel)
getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
notificationManager?.createNotificationChannel(channel)
} }
return NotificationCompat.Builder( return NotificationCompat.Builder(

Loading…
Cancel
Save