Я уже пробовал использовать различные виды уведомлений, которые появляются в журнале уведомлений на часах, но не отображаются. всплывающее окно на циферблате.
Код Kotlin:
Код: Выделить всё
private fun createNotification(title: String, text: String): Notification {
val notificationIntent = Intent(this, ThresholdAchieved::class.java)
val pendingIntent = PendingIntent.getActivity(
this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE
)
val channel =
NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH)
getSystemService(NotificationManager::class.java).createNotificationChannel(channel)
return NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(title)
.setContentText(text)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setSmallIcon(R.drawable.splash_icon)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build()
}
Код: Выделить всё
startForeground(NOTIFICATION_ID_2, createNotification("TestNotification","This is a test notification"))
Код: Выделить всё
Я рад каждому полученному сообщению, спасибо!< /п>
Подробнее здесь: https://stackoverflow.com/questions/790 ... ically-ope