gpt4 book ai didi

android - 如何取消 Notification.FLAG_FOREGROUND_SERVICE

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

假设您希望显示带有前台服务标志的通知,并使用 nm 来显示它:

Notification notification = new Notification(...);
notification.flags |= Notification.FLAG_FOREGROUND_SERVICE
nm.notify(SOME_ID, notification);

通知将会出现。但是,删除它很困难,因为这似乎没有任何作用:

nm.cancel(SOME_ID);

如何取消这个通知? stopForeground 不是解决方案,因为我不在服务中。

最佳答案

is there any solution?

如果this issue可以相信,那么不,除了有一个服务调用 stopForeground()。您可以通过 startService() 向您的服务发送命令,以便它可以调用 stopForeground()。或者,您可以创建一个小型专用 Service,它只需从 onStartCommand() 调用 stopForeground()stopSelf() >,只是为了摆脱这个通知。

关于android - 如何取消 Notification.FLAG_FOREGROUND_SERVICE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15022990/

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