I have my main activity that can bind a service and call a service method.
The service method start a thread (in service) that download data and store them in db. At the end of download the thread can be restarted.
What happen if activity call unbindService (i.e. in onPause)? Service is destroyed and thread stopped or the service is destroyed when all task end?
If the service was previously started using the
startService()method and then bound to it, after unbind the service will continue running.If you just started the service by using
bindService()which creates the service if it is not running after unbind if no otherActivityis bound to the service, the service will stop.