I have a Service singleton class with static methods that I call from the same process. I call startService when my Application starts. I also call bindService, but now I am wondering if that is really necessary.
+1
A:
It depends on whether you need to call instance methods on that service or not. StartService gets the service up and running and working on whatever Intent you sent it but you still can't interact with it because you don't have a reference to the service object. Calling bindService is what gives that reference so that you can call instance methods on it. If you don't need that, you don't need bindService.
Jere.Jones
2010-06-30 21:41:25
Yes I need to call methods on that service but I am calling static methods.I guess the only reason I see bindService being useful is having the "onServiceConnected" and "onServiceDisconnected" methods being called, so that you know when your service starts and stops respectively. In my case my service is supposed to run all the time and so those methods are not so useful.Or am I missing something here?
Erdal
2010-06-30 23:01:14
Your service's lifetime extends beyond onServiceConnected and onServiceDisconnected. onCreate and onDestroy are better measurements of lifetime.
Jere.Jones
2010-07-01 01:30:50
that's true. so I still don't see the use for bindService in a local process.
Erdal
2010-07-01 02:44:47
In your particular instance there is no use so you shouldn't use it. There are valid uses for it though.
Jere.Jones
2010-07-01 04:07:26