android - Set Timeout on Asynchronous Http Client -
im using asynchronous http client can found here: http://loopj.com/android-async-http/
and works great besides 1 out of every 10 or requests make end giving me infinite progress dialog believe means whatever reason no response of kind being returned because have written code dismiss dialog in onsuccess , onfailure im bit confused how happen.
here code sets request:
public static void post(string token,string url, requestparams params, asynchttpresponsehandler responsehandler) { log.i(token,"token"); client.addheader("token", token); client.settimeout(3000); client.post(url, params, responsehandler); }
and here override onsuccess , onfailure:
@override public void onfailure(throwable arg0, string arg1) { // todo auto-generated method stub super.onfailure(arg0, arg1); pdialog.dismiss(); log.i("failed login", arg1.tostring()); toast.maketext(getactivity(), arg1.tostring() , toast.length_long).show(); } @override public void onsuccess(final jsonobject json) { pdialog.dismiss(); }
the library seems doing want do, settimeout
code asynchttpclient
class
public void settimeout(int timeout){ final httpparams httpparams = this.httpclient.getparams(); connmanagerparams.settimeout(httpparams, timeout); httpconnectionparams.setsotimeout(httpparams, timeout); httpconnectionparams.setconnectiontimeout(httpparams, timeout); }
if not working better report issue here
Comments
Post a Comment