0

When i call stopForeground in api level 19 then service will destroy but when i call stopForeground in api level 24 then service will not destroy can anyone help me to find out this scenario in api level 20 ,21 , 22 and 23?

hio
  • 915
  • 8
  • 26
  • Have you gone through [this](https://stackoverflow.com/questions/20857120/what-is-the-proper-way-to-stop-a-service-running-as-foreground/20857343)? – Piyush Aug 08 '19 at 06:45
  • i test it in emulator with api level 23, 22 its working, now i am downloading 21 and 20 then check it – hio Aug 08 '19 at 07:20
  • now i test 21 and 20 api its working – hio Aug 08 '19 at 08:35

1 Answers1

0

What flag are you providing stopForground(int) docs state that using STOP_FOREGROUND_REMOVE although unclear mention it could destroy the service.

You could try using the flag STOP_FOREGROUND_DETACH and manually delete the notification if no longer required through the NotificationManager.

Docs for reference : stopForground(int) flags

Muto
  • 61
  • 6