android - Retrofit continuous query not working properly in mobile network -
i using retrofit parsing json api. when using mobile network (not wifi) continuously making query retrieve response api getting time out error.
code :
userlogin("username"). enqueue(new retrofitcallback<patientmodel>() { @override public void onsuccess(patientmodel result) { if (null != result) { loginresponse(result); } } @override public void onfailure(int code, string msg) { } @override public void onthrowable(throwable t) { } @override public void onfinish() { hideprogress(); } });
maybe must increase time out. try :
gson gson = new gsonbuilder() .setdateformat("yyyy-mm-dd't'hh:mm:ss") .create(); okhttpclient = new okhttpclient().newbuilder() .connecttimeout(120, timeunit.seconds) .readtimeout(120, timeunit.seconds) .writetimeout(120, timeunit.seconds) .build(); retrofit = new retrofit.builder() .baseurl(constants.base_url).client(okhttpclient) .addconverterfactory(gsonconverterfactory.create(gson)) .build(); apiservice = retrofit.create(iservice.class);
Comments
Post a Comment