Skip to main content

A few things:

  1. Get rid of the mNotificationManager.notify(NOTIFICATION_ID, notification);. startForeground displays the notification icon for you.

    Get rid of the mNotificationManager.notify(NOTIFICATION_ID, notification);. startForeground() displays the notification icon for you.

  2. Foreground services can still be killed, they're just less likely to be.

    Foreground Services can still be killed, they're just less likely to be.

  3. There's a bug in 2.3 (not sure if it was fixed yet) where when a service is killed and restarted it's onStartCommand will NOT be called again. Instead you're going to have to do any setting up in onCreate.

    There's a bug in 2.3 (not sure if it was fixed yet) where when a Service is killed and restarted, its onStartCommand() will NOT be called again. Instead you're going to have to do any setting up in onCreate().

A few things:

  1. Get rid of the mNotificationManager.notify(NOTIFICATION_ID, notification);. startForeground displays the notification icon for you.
  2. Foreground services can still be killed, they're just less likely to be.
  3. There's a bug in 2.3 (not sure if it was fixed yet) where when a service is killed and restarted it's onStartCommand will NOT be called again. Instead you're going to have to do any setting up in onCreate.

A few things:

  1. Get rid of the mNotificationManager.notify(NOTIFICATION_ID, notification);. startForeground() displays the notification icon for you.

  2. Foreground Services can still be killed, they're just less likely to be.

  3. There's a bug in 2.3 (not sure if it was fixed yet) where when a Service is killed and restarted, its onStartCommand() will NOT be called again. Instead you're going to have to do any setting up in onCreate().

Source Link
Kevin TeslaCoil
  • 10.1k
  • 1
  • 40
  • 33

A few things:

  1. Get rid of the mNotificationManager.notify(NOTIFICATION_ID, notification);. startForeground displays the notification icon for you.
  2. Foreground services can still be killed, they're just less likely to be.
  3. There's a bug in 2.3 (not sure if it was fixed yet) where when a service is killed and restarted it's onStartCommand will NOT be called again. Instead you're going to have to do any setting up in onCreate.