For the Application object, I call bindService()
. The onServiceConnected()
callback receives an IBinder
object, and I hand that to an AsyncTask
.
There, I get my service object by calling ServiceClass.Stub.asInterface(iBinderObject)
and call some method using this service object.
It's a synchronous method and I cannot influence the service's timeout setting (and who knows whether its timeout implementation is reliable). So, beforehand, I postDelayed()
my own timeout handler on a separate thread.
The timeout code calls unbindService()
to unbind the Application from the service and yields a timeout result.
I haven't found a way to interrupt the service call if the timeout runs first. The unbindService()
has no visible effect wrt this. Calling AsyncTask.cancel(true)
changes nothing, either. The IBinder
object does not seem to provide any obvious method which could be of any help.
What I observe is that the AsyncTask
keeps waiting for the service call to return, which can delay the start of the next AsyncTask
significantly with the standard Executor
.
Any experiences? Ideas?