What the idiomatic way of doing this in Kotlin? ``...
# getting-started
s
What the idiomatic way of doing this in Kotlin?
Copy code
if (mNotificationManager == null) {
                mNotificationManager = this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
 }
e
Copy code
val notificationManager by lazy {
    context.getSystemService<NotificationManager>()
}
androidx.core.content.getSystemService avoids a cast, kotlin.lazy handles init-once
👍 1