【发布时间】:2018-10-17 10:10:08
【问题描述】:
我正在 Wear OS(Android 8+)上开发一个独立的应用程序,但我遇到了通知问题。
我正在运行Foreground Service,并持续收到通知。该持续通知运行良好,并且没有来自 Wear OS 的功能(因此代码可以在独立的 Android 上运行)。
但是,每当我想显示其他通知时,这是不可能的。
没有错误消息,什么都没有:我的通知没有显示。 我确保创建单独的频道并启用它们(通过设置)。
这是我的代码,通过Handler 在Looper.mainLooper() 中运行。
final Notification notification = new NotificationCompat.Builder(MonitorService.this, LOGS_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_backup_logs) // vector (doesn't work with png as well)
.setContentTitle(getString(R.string.monitor_service_notification_log_file_backed_up_process))
.setContentText("test")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.build();
notificationManagerCompat.notify(LOGS_ID, notification); // unique final static id
我在这里错过了什么吗?
感谢您的帮助!
【问题讨论】:
标签: android android-notifications wear-os android-wear-notification