[android-developers] Re: How could I know a Service is already started?

2009-01-05 Thread yukinoba
Ummm... does anyone know? have any ideas? On 1月5日, 下午12時05分, yukinoba wrote: > To dear all Android developers, > > Is there a way to check whether a service is already started or not? > This issue has been discussed ealier (and much earlier) in April, in > the last year, on this forum. > > http:

[android-developers] Re: How could I know a Service is already started?

2009-01-05 Thread yukinoba
Hi all, I have already found out how to get this done. Please refer to the following code: /** * Indicates whether the specified service is already started. This * method queries the activity manager for launched services that can * respond to an binding with an specific servi

[android-developers] Re: How could I know a Service is already started?

2009-01-05 Thread Dianne Hackborn
I would strongly recommend against that, it can be quite inefficient. This API is really intended for applications to display a list of running services. If your service is running in the same process as the code wanting to check its state, you can just set a global variable while it is running.

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread yukinoba
to dear Dianne, I need to implement a remote background service and a service controller activity. I want to present an effect which the controller activity could know whether or not this service is already started, and enable / disable the menu button which is used to start / bind / unbind / sto

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread Dianne Hackborn
To monitor the state of a service, I suggest binding to it without the flag to create it. Then you will not cause it to start, but be told when it is created or destroyed via the appropriate callbacks. On Tue, Jan 6, 2009 at 1:24 AM, yukinoba wrote: > > to dear Dianne, > > I need to implement a

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread yukinoba
to dear Dianne, I see your point. However, when I try to bind the service without BIND_AUTO_CREATE flag, I expect it will return false to me. But the bindService method always returns true. This is a weird behavior for bindService with a flag 0. the code I used is following: isBound = bindServic

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread yukinoba
to dear Dianne, I see your point. However, when I try to bind the service without BIND_AUTO_CREATE flag, I expect it will return false to me. But the bindService method always returns true. This is a weird behavior for bindService with a flag 0. the code I used is following: isBound = bindServic

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread yukinoba
Hi, I have tried this again with the RemoteServiceBinding example in the ApiDemos example packages. I turned the flag argument to Context.BIND_AUTO_CREATE, Context.BIND_DEBUG_UNBIND, or 0, and found out the return value of bindService is always true. More than this, when I left the RemoteService

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread Dianne Hackborn
The return value just indicates that there is infact a service that can be started, so true means all is good. What you care about for knowing whether the service is actually started are the callbacks to your connections. (Be sure your services publishes an IBinder for the Intent you are binding

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread Moto
I'm also interested on your solution but could you explain a little more? new Binder? Thanks, Moto! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to andr

[android-developers] Re: How could I know a Service is already started?

2009-01-06 Thread Dianne Hackborn
The LocalServiceBinding API demo should be a good example, you'll just want to bind without the BIND_AUTO_CREATE flag so the service doesn't get created as a result of your own binding. On Tue, Jan 6, 2009 at 7:32 PM, Moto wrote: > > I'm also interested on your solution but could you explain a l

[android-developers] Re: How could I know a Service is already started?

2009-01-07 Thread yukinoba
to dear Dianne, I don't think using remote callback is a good idea and mechanism. :-( The callback of ServiceConnection can only be triggered "when the service is already started" but not "when the service is not yet started", and there will be a confusion during waiting for the callback is trig