gpt4 book ai didi

安卓通知 : How to show sticky/updating alarm

转载 作者:行者123 更新时间:2023-12-04 04:18:20 24 4
gpt4 key购买 nike

我有一个应用程序,我想在屏幕顶部显示一个通知,随着时间的更新,并让它留在那里直到用户关闭它或按下一个 Action 。

我的问题是,如何让通知以这种方式停留在屏幕顶部,并且是否也可以更新?

Example

最佳答案

要使提醒通知留在那里,您需要使用

PendingIntent dummyIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
notification.setFullScreenIntent(dummyIntent, true);
我从这篇文章中得到的理解是,应用程序认为它应该保持在那里,直到全屏 Intent 采取行动,但它永远不会因为它是一个虚拟 Intent 。
https://stackoverflow.com/a/45516069/6296686
更新通知使用
notificationBuilder.setOnlyAlertOnce(true);

//Use the same builder when updating
notificationBuilder.setContentTitle("Updated Title");
notificationManager.notify(notificationID, notificationBuilder.build());
https://stackoverflow.com/a/15538209/6296686

关于安卓通知 : How to show sticky/updating alarm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60043093/

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