gpt4 book ai didi

android - 如何在应用程序被杀死时在状态栏上保持通知?

转载 作者:行者123 更新时间:2023-12-05 07:50:57 25 4
gpt4 key购买 nike

当我长按主页按钮并终止我的应用程序时,通知从状态栏中删除,但我想在应用程序终止时保留它,如何在应用程序终止时在状态栏上保留通知?

最佳答案

你可以做的是使用:

startForeground()

Note: You can set this flag if killing your service would be disruptive to the user, such as if your service is performing background music playback, so the user would notice if their music stopped playing.

Example 1

Example2

并停止这种使用:

stopForeground()

Note: Remove this service from foreground state, allowing it to be killed if more memory is needed.

希望对您有所帮助。

关于android - 如何在应用程序被杀死时在状态栏上保持通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35646495/

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