gpt4 book ai didi

android - 更新通知的 tickerText

转载 作者:行者123 更新时间:2023-11-29 18:18:48 24 4
gpt4 key购买 nike

我在通知方面遇到了一个奇怪的问题。

我创建了一个持续通知,我想有时更新通知并显示新的代码文本。

当我创建通知时,代码文本正确显示。
当我第一次更新通知时(使用下面的代码),新的代码文本正确显示。
当我第二次使用与第一次完全相同的代码和相同的参数(特别是相同的新代码文本)更新通知时,不显示代码文本。

问题出在哪里?

代码:

mNotification.tickerText = newTickerText;
mNotification.when = System.currentTimeMillis();
mNotification.setLatestEventInfo(activity, title, message, pIntent); // I don’t think these arguments are relevant, but I can post more code if you want
nm.notify(42, mNotification); // nm is the NotificationManager

编辑:
好吧,我找到原因了,Android不想再显示和以前一样的ticker文本了。有解决方法吗?

编辑#2:
我的应用程序是多人游戏,我必须在用户连接期间保持网络套接字打开。
但我不想在用户收到新短信并想阅读时突然断开连接(例如)。我想要的是让正在进行的通知说“您将在 30 秒后断开连接”。
我在用户连接时遇到上述问题,离开应用程序,不到 30 秒后回来,然后再次离开应用程序。只有当用户反复离开并返回我的应用程序时,我才会反复闪烁相同的消息(我想这不应该经常发生)

您认为这会骚扰用户吗?我应该怎么做?

最佳答案

Is there a workaround for that?

具有用户会重视的有意义的不同文本。请勿反复刷同一条消息骚扰用户。


更新基于编辑

What I want is to have the on going notification saying something like "You will be disconnected in 30 seconds".

没关系。

I have the problem above when the user is connected, leave the application, come back less than 30 seconds after, and then leave the application again.

用户回到您的 Activity ,这是您应该取消通知的地方,在这种情况下您可以毫无问题地重新显示相同的代码消息。

关于android - 更新通知的 tickerText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6671031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com