1

After I killed the application (incl. foreground service) through the app settings, then the notification icon that is bind to the foreground service remains visible.

Is it possible to remove the icon after the application was killed?

Sebastian
  • 375
  • 3
  • 14
  • possible duplicate https://stackoverflow.com/questions/12997800/cancel-notification-on-remove-application-from-multitask-panel – Anubhav Gupta Sep 14 '18 at 09:25
  • Thanks for the link. The problem is a little bit different but similar and I found the solution with the answers in this thread. – Sebastian Sep 14 '18 at 13:34

1 Answers1

1

Based on the answers here I found a solution (thx @Anubhav Gupta).

You can override the onTaskRemoved function in which the foreground service can be stopped.

@Override
public void onTaskRemoved(Intent rootIntent) {
    Intent intent = new Intent(this, MyService.class);
    context.stopService(intent);
}
Sebastian
  • 375
  • 3
  • 14