0

I am creating a service... binding configurator to it, but I would like to unbind configurator on close and leave service running... But when I unbind, service stopps itself, and without unbinding, service crashes with error about leaked service connection... so what should I do?

I am creating service without BIND_AUTOCREATE flag. Using startService.

1
  • 2
    If you give -1, at least tell me why. Commented Jun 23, 2014 at 17:49

3 Answers 3

1

You should be able to start a background Service using an intent and startService() which isn't bound to your activity and shouldn't leak or crash, I'm not sure what you are using the configurator for as I have never bound a service besides in AIDL calls, can you pass in arguments instead?

I'm not the downvoter, although I think you need to attach some code. If you attach the code leave a comment and I'll see if I can update my answer to be any more help.

Sign up to request clarification or add additional context in comments.

1 Comment

Configurator binds to service to receive a status of tasks made by it.
0

I think you should not bind the service, just startService() will do. When you need to communicate between UI process and Service process, AIDL is there to help.

I usually use AIDL strong binder as callback for service process to execute. You can checkout my library for some example: hogwarts library

Comments

0

This question may be mixing a bunch of different issues.

I think that the problem is that the word "started", when used with services, has nothing to do with actually accomplishing useful work. A service doesn't really "run". Service code gets executed in response to exactly two things: intents and requests from bound clients.

Your service definitely does not stop itself, when you unbind from it. If it was started, it stays started. If it wasn't started, it still isn't. I'd like to understand more about what is "running" so that it crashes, when you unbind the service.

When your configurator goes away without unbinding the service, then you've leaked a Binder connection. That gets you a warning, but it probably isn't a big deal: Binder should take care of it.

2 Comments

You can bind to running service without (re)starting it by simply giving 0 as last param. And I do so. It does crash when I dont unbind, and stops running when unbinding.
Right! That's what I said! Binding to a service and starting it are two separate actions. If you bind to it, without starting it, when you unbind, there is nothing to run. I'd love to see the stack trace for the crash.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.