2

I would like to use a foreground service in my application. I managed to start it using startForeground(FOREGROUND_SERVICE_ID, notification) in my service class.

However, I want my service be killed when app is killed (= onDestroy() of my activity). However, using stopForeground(true) and stopSelf() doesn't seem to work if I call it from the onDestroy of my activity. However, it works if I call this from the onStart() method.

Is it possible to kill the foreground service when the app is killed and not only stopped ?

I used intent to use my service from my activity like this : http://www.truiton.com/2014/10/android-foreground-service-example/

Thank you for your answers and don't hesitate if you need more precisions.

Boysteuf
  • 213
  • 3
  • 10

0 Answers0