android - OkHttp3 doesn't load all json data from server -


im going take user data server in json format. php generate code cool can not json in okhttp response. in fact load part of json not of them.

plus: reason use code want take user data server in login process. here code in

import android.os.asynctask; import android.util.log;  import com.example.android.shopping.helper.tags; import com.example.android.shopping.model.suggestion; import com.example.android.shopping.model.product; import com.example.android.shopping.model.user;    import java.io.ioexception; import java.util.arraylist; import java.util.list;  import okhttp3.multipartbody; import okhttp3.okhttpclient; import okhttp3.request; import okhttp3.requestbody; import okhttp3.response;  /**  * created android on 7/21/2016.  */ public class selectall_info_networkcalltask extends asynctask <string,void,string>{     public static list<product> listofproduct=new arraylist<>();     public static list<suggestion> listofsuggestion=new arraylist<>();     public static user myuser=new user();       public user getuser=new user();     private okhttpclient client=new okhttpclient();     string result="";     public selectall_info_networkcalltask(user user)     {         this.getuser = user;     }      @override     protected string doinbackground(string... params) {          try {             requestbody requestbody;             requestbody = new multipartbody.builder()                     .settype(multipartbody.form)                     .addformdatapart("action", getuser.getstatus())                     .addformdatapart("userid",string.valueof(getuser.getusid()))                     .build();              request request = new request.builder()                     .url(tags.selectalladdress)                     .post(requestbody)                     .build();              response response = client.newcall(request).execute();              result=response.body().string();              return result;          }  catch (ioexception e) {             e.printstacktrace();         }           return  null;     }      @override     protected void onpostexecute(string o) {         super.onpostexecute(o);          log.d("output is:",o);       } } 

and how call it:

   public void regform(view view)     {      /*   intent intent=new intent(this,registeruseractivity.class);         startactivity(intent);*/         user myuser=new user();         myuser.setstatus("palt");         myuser.setusid(22);         selectall_info_networkcalltask infocalltask=new selectall_info_networkcalltask(myuser);         infocalltask.execute();     } 

and this expected , gotten data shared on gist

well first; should not using asynctask okhttp. okhttp has own asynchronous callback:

client.newcall(request).enqueue(new callback() {      @override     public void onfailure(call call, ioexception exception) {         exception.printstacktrace();     }      @override     public void onresponse(call call, response response) {         // handle response     }  } 

secondly, answer question; logcat has maximum message output device dependent. therefore, outputting string longer maximum truncated. so, okhttp receiving entirety of response, logcat cannot display of in 1 message.


Comments