android service startService() and bindService()

I think hara’s answer was a little confusing. What you describe is perfectly legitimate and in fact the only way to get the behavior you want. If you create a Service by binding to it, it will die when you unbind. So the only way to keep it around without activities binding to it is to start it with startService(). There is no conflict with lifecycles because it only applies to how the service is STARTED. So once it’s started with startService(), it follows that lifecycle process. So you are free to bind and unbind to it as much as you wish and it will only die when you call stopService() or stopSelf().

Leave a Comment