From 360e1032951a2b3fe48ec6cc509c1c72bb572a8f Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 11 Jul 2025 13:46:22 +0200 Subject: [PATCH] Simplify access to platform's `getSystemService` with reified Androidx's version --- .../apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt index 6c4a29373..28be12fa1 100644 --- a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt +++ b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt @@ -22,6 +22,7 @@ import android.app.NotificationManager import android.content.Context import android.os.Build import androidx.core.app.NotificationCompat +import androidx.core.content.getSystemService import androidx.work.Constraints import androidx.work.ForegroundInfo import androidx.work.NetworkType @@ -60,10 +61,7 @@ private fun Context.syncWorkNotification(): Notification { description = getString(R.string.sync_work_notification_channel_description) } // Register the channel with the system - val notificationManager: NotificationManager? = - getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager - - notificationManager?.createNotificationChannel(channel) + getSystemService()?.createNotificationChannel(channel) } return NotificationCompat.Builder(