android - FileAsyncHttpResponseHandler cancel request -
i want cancel fileasynchttpresponsehandler request in android app, 1 (not of them). there these methods available, none of them cancel request. proceeds until file downloaded.
fileasynchttpresponsehandler fileasynchttpresponsehandler; ...get request... fileasynchttpresponsehandler.deletetargetfile(); fileasynchttpresponsehandler.oncancel(); fileasynchttpresponsehandler.sendcancelmessage();
please me!!
i'm dev of said library, , have 3 options.
first, obtain requesthandle
creating request, , cancel through that
asynchttpclient ahc = new asynchttpclient(); requesthandle rh = ahc.get(context, url, fileresponsehandler); rh.cancel();
second, cancel request belonging context
asynchttpclient ahc = new asynchttpclient(); ahc.get(currentactivity.this, url, fileresponsehandler); ahc.cancelrequests(currentactivity.this, boolean mayinterruptifrunning);
third, in 1.4.8 snapshot (will released in on sunday 1.4.8 release), put tag request (or implement gettag()
in responsehandler, , cancel said tag)
string mytag = "my-long-identifier-such-as-uuid"; asynchttpclient ahc = new asynchttpclient(); requesthandle rh = ahc.get(context, url, fileresponsehandler); rh.settag(mytag); ahc.cancelrequestsbytag(mytag, boolean mayinterruptifrunning);
or implementing gettag() response handler
asynchttpclient ahc = new asynchttpclient(); ahc.get(context, url, new fileasynchttpresponsehandler(){ // implement methods // override gettag() identify request associated responsehandler // example return "url" ability cancel request url @override public object gettag() { return url; } }); ahc.cancelrequestsbytag(url, boolean mayinterruptifrunning);
Comments
Post a Comment