问题
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?
回答1:
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 other Activity is bound to the service, the service will stop.
来源:https://stackoverflow.com/questions/6830812/android-bound-service-what-happen-when-activity-unbound-it