【问题标题】:Android: How to create a permanent notification using NotificationChannelAndroid:如何使用 NotificationChannel 创建永久通知
【发布时间】:2019-03-14 07:49:27
【问题描述】:

您知道我应该使用哪种方法在 Android Pie 中使用 NotificationChannel 创建永久通知吗?更准确地说,是用户无法删除的通知。

【问题讨论】:

  • “永久通知”是什么意思?你试过什么?
  • 用户无法删除的通知(我编辑了问题)
  • 您在服务中发出通知?
  • 启动前台服务
  • 此外,当您通过startForeground(SERVICE_ID, notification); 调用通知时,如果您不调用stopForeground(true); 并且未更改通知的FLAG_AUTO_CANCEL,则用户无法将其删除。

标签: android notification-channel


【解决方案1】:

如果我正确理解您的问题,那么您的永久通知称为持续通知。

你可以使用

setOngoing(true)

为你的

NotificationCompat.Builder

但是这个问题似乎是重复的:请在此处查看更多信息:

Android: How to create an "Ongoing" notification?

【讨论】:

  • 不,因为我说的是 NotificationCHannel,而您显示的问题并非如此
  • 通知通道是在您通过该通道发送通知之前创建的,因为发送通知您可能仍然会使用 NotificationCompat,您可以在其中使用 setOngoing。或者您的意思是您希望频道的所有通知都持续进行?我不确定 Android SDK 是否可行据我所知,您必须为每个通知单独设置它。
  • 哈好!感谢您的回复!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多