Код: Выделить всё
private fun createNotificationChannel() {
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel(Notification.CATEGORY_REMINDER, "Reminder to Edit Trip", importance).apply {
description = "Send half-hourly reminders to edit the details of a trip."
}
val notificationManager: NotificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager //TODO
notificationManager.createNotificationChannel(channel)
}
Код: Выделить всё
NotificationManager notificationManager = getSystemService(NotificationManager.class)
Код: Выделить всё
private val alarmManager = context.getSystemService(AlarmManager::class.java)
Я нашел этот вопрос SO по той же проблеме, но ответ больше не работает, поскольку в context больше нет getSystemService(). Я попробовал оба
Код: Выделить всё
val notificationManager = Context.getSystemService(Context.NOTIFICATION_SERVICE)
и
Код: Выделить всё
val notificationManager = ContextCompat.getSystemService(Context.NOTIFICATION_SERVICE);
Так как мне теперь это написать? Я ориентируюсь на API 30.
Подробнее здесь: https://stackoverflow.com/questions/789 ... und-string