Android: How to cancel/interrupt a synchronous Service call? -
for application object, phone call bindservice()
. onserviceconnected()
callback receives ibinder
object, , hand asynctask
.
there, service object calling serviceclass.stub.asinterface(ibinderobject)
, phone call method using service object.
it's synchronous method , cannot influence service's timeout setting (and knows whether timeout implementation reliable). so, beforehand, postdelayed()
own timeout handler on separate thread.
the timeout code calls unbindservice()
unbind application service , yields timeout result.
i haven't found way interrupt service phone call if timeout runs first. unbindservice()
has no visible effect wrt this. calling asynctask.cancel(true)
changes nothing, either. ibinder
object not seem provide obvious method of help.
what observe asynctask
keeps waiting service phone call return, can delay start of next asynctask
standard executor
.
any experiences? ideas?
as others have noted, synchronous phone call cannot interrupted.
if concern, , have input in design of service api, can perform asynchronous operations using pair of one-way aidl interfaces, this:
package sample; oneway interface iserver { void dowork(iclient cb); }
and
package sample; oneway interface iclient { void reportresult(string result); }
android android-service request-cancelling
No comments:
Post a Comment