悄悄地更新正在进行的通知 [英] Updating an ongoing notification quietly

查看:20
本文介绍了悄悄地更新正在进行的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一项可以无线连接到其他设备的服务.启用该服务后,我会收到一条持续通知,说明它已启用.

I have a service which connects to other devices wirelessly. When the service is enabled, I have an ongoing notification which states it is enabled.

启用该服务后,用户将连接到另一台设备.在这一点上,我想更新我的正在进行的通知,以说明已连接到的设备的名称.这很容易通过使用更新的信息再次调用 startForeground(ONGOING_NOTIFICATION, notification) 来完成;但是,每次调用时都会在栏上闪烁通知.我真正想要的是通知在后台悄悄更新而不在通知栏上闪烁,这样用户在打开通知区域查看之前不知道区别.

After the service is enabled, the user then connects to another device. At this point, I would like to update my ongoing notification to state the name of the device which has been connected to. This is easy enough to do by calling startForeground(ONGOING_NOTIFICATION, notification) again with the updated information; however this flashes the notification on the bar each time it is called. What I would really like is the notification to quietly update in the background without flashing on the notification bar so the user doesn't know the difference until he or she opens the notification area to look.

有没有办法在不调用startForeground()的情况下更新通知?

Is there someway to update the notification without calling startForeground()?

此行为仅发生在 Honeycomb 中.姜饼设备(我假设 Froyo 等)的行为符合预期.

This behavior only occurs in Honeycomb. Gingerbread devices (and I assume Froyo, etc.) behave the desired way.

推荐答案

您应该更新现有通知 https://developer.android.com/training/notify-user/build-notification.html#Updating

这篇关于悄悄地更新正在进行的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆