【问题标题】:Update only part of an Android notification with custom layout使用自定义布局仅更新 Android 通知的一部分
【发布时间】:2012-03-05 00:17:08
【问题描述】:

我创建了一个带有自定义布局的 Android 状态栏通知,其中包含一个按钮和一个文本视图(我使用 ICS api)。 当按钮被按下时,它会向广播接收器发送一个挂起的意图。当接收者收到意图时,我希望它更新通知中的文本视图。如果不重新创建一个全新的通知并传递相同的 ID,这是否可能?

在广播接收器中创建 pendingintent 时出错“PendingIntent 类型中的方法 getBroadcast(Context, int, Intent, int) 不适用于参数 (lereceiver, int, Intent, int)” 相同的代码适用于创建通知的活动

任何帮助将不胜感激!

【问题讨论】:

  • 这个文本视图在你的自定义布局中的什么位置,是在用户选择通知之后?
  • 文本视图在通知的自定义布局中。我通过使用 notification.builder 并仅传递我想要修改的部分解决了这个问题。感谢回复

标签: android notifications broadcastreceiver android-pendingintent


【解决方案1】:

使用相同的通知 id 传递更新的通知

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-28
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多