I was wondering if there was any technique to bind to a local service
synchronously. Of course if the service was remote it would be an
especially bad idea, but binding to a local service seems to happen
quickly.

The situation i often run into is that
ServiceConnection.onServiceConnected() isn't called at a convenient
time. For example, if you want to invoke a method on a local service
in onActivityResult() but bind/unbind on onStart/onStop. The service
still won't be available by the time onActivityResult() is called.

I did come across this:

http://code.google.com/p/google-cache-invalidation-api/source/browse/trunk/src/java/com/google/ipc/invalidation/external/client/android/service/ServiceBinder.java

Which uses a CountdownLatch to gate the calling thread, but my
attempts to use it have resulted in deadlock.

I even tried binding to the service from another thread, hoping that
ServiceConnection.onServiceConnected() would be called from the thread
which called bindService, but this does not seem to be the case.

Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to