As a developer who's new to android I think I've perhaps misunderstood the bound service.
I've created a service to wrap up access to a server. As part of this service, the service is listening to a multicast address to identify when devices on the local network appear and disappear.
However I'm having problems due to there being multiple instances of the service started. This happens when the activity is closed (using the back button) and then re-opened shortly after. The effect is that the service is unable to bind to the local port and so can not listen to the multicast.
I had thought that the bound service would die once the activity stopped but this appears not to be the case.
Have I misunderstood the bound service or am I doing something else wrong?
Edit
So it seams my misunderstanding was that I'd assumed the program would be cleaned up as soon as the last non-daemon thread was closed and that would be as soon as the activity terminated.
I've fixed this by explicitly cancelling the listening thread and closing the socket in onDestroy()
.