0

Well lets say that I have a service that plays your music (like Google Music) my service works perfectly, but if the user exit the app , pressing back button or removing it from recents, my service call onDestroy wait ~5secs and calls onCreate again.

So the question is, how I can make it stay alive until the user close it with a button? (Just like Gogle Music does)

Rotary Heart
  • 1,899
  • 3
  • 29
  • 44
  • I think you should search for your answer here: http://stackoverflow.com/questions/3141996/android-how-to-override-the-back-button-so-it-doesnt-finish-my-activity – DmitryK Jan 06 '13 at 04:10
  • That won't help since the user can exit the app removing it from recent apps. So the service got killed again. – Rotary Heart Jan 06 '13 at 04:12

1 Answers1

2

You can start your service as foreground using Service.startForeground

Vladimir Mironov
  • 30,514
  • 3
  • 65
  • 62