androidandroid-serviceandroid-service-binding

Never call unbindService() method on a Service?


I have scenario(for theoretical purposes):

What happens if, say, there is only one Activity that is bound to a Service and it decides to never call unbindService() method?

Will the Service ever get destroyed, in this case?


Solution

  • Whenever the Context that bound to a service is destroyed, The OS is supposed to unbind it for you. According to Google's documentation, calling unbindService() yourself is recommended because "Doing so allows the idle service to shut down", but that's not a requirement