删除被杀死的前台服务(Android)的通知图标

问题描述 投票:0回答:1

通过应用程序设置终止应用程序(包括前台服务)后,绑定到前台服务的通知图标仍然可见。

应用程序被杀后是否可以删除图标?

android android-notifications foreground-service
1个回答
0
投票

基于here的答案,我找到了一个解决方案(thx @Anubhav Gupta)。

您可以覆盖可以停止前台服务的onTaskRemoved函数。

@Override
public void onTaskRemoved(Intent rootIntent) {
    Intent intent = new Intent(this, MyService.class);
    context.stopService(intent);
}
© www.soinside.com 2019 - 2024. All rights reserved.