androidservicelow-memory

Android Service killed low memory - how to let user know


I have an app who's activity starts a service to play a downloaded podcast. As the user pressed the BACK key to get to the hope screen the service continues to play the podcast as expected. However if the user launches a broswer (doesn't matter which one) and navigates to a page that loads a bunch of high res images, (of which I can recreate over and over), my service is being killed by the OS due to low memory(I'm guessing).

As a result I'm getting nailed for having an app that "crashes" when it is not crashing, the service is getting yanked.

The STICKY flags don't give me the option of exiting gracefully or letting the user know what happened.

How does a service get around letting the user know that it was terminated because of an outside app?


Solution

  • Make sure your service is running in the foreground. This has the bonus of showing a notification whilst your service is running too.