Question

I've got an app that runs in the background, using a service. But when onDestroy is called in the main activity, the service gets reseted, calls onCreate and onStart over again. How can i prevent this?

Was it helpful?

Solution

you have to look at the value the service returns from its onStartCommand method. The default value is START_STICKY which will restart the service after it is destroyed. Take a look at the onStartCommand documentation for more details:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top