2

I'm using Volley to make a GET request to an API:

    StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Log.i("RESPONSE",response);

            //this method parses the JSON response and fills it into a custom ArrayList
            parseResponse(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.i("Sorry", "unable to get the response!");
        }
    });

The expected JSON object response is big (could be upto 500 KB). I'm unable to see the complete response in my logs. Only the first 50 lines or so are displayed. I'm also getting BasicNetwork.logSlowRequests info:

BasicNetwork.logSlowRequests: HTTP response for request=<[ ]

which means the request is taking more than 3000 ms.

Things tried:

I've increased the logger buffer sizes to 1M in Developers Options in the phone.

What could be the reason? Is the response sent in chunks when it's big? If so, how to join them to parse the full response?

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91

1 Answers1

2

Log does not show the complete string if it very big ,try writing to a file on disk and check it should be complete.

Also you can use this method to print complete log:

public static void longInfo(String str) {
    if(str.length() > 4000) {
        Log.i(TAG, str.substring(0, 4000));
        longInfo(str.substring(4000));
    } else
        Log.i(TAG, str);
}
JAAD
  • 12,349
  • 7
  • 36
  • 57
  • Thanks, I'm trying that. I'll update if I see the complete response. – Akeshwar Jha Feb 22 '16 at 05:38
  • @user5038993 -- but you can increase, although i never tried that myself -- http://stackoverflow.com/questions/4655861/displaying-more-string-on-logcat – Tasos Feb 22 '16 at 05:39
  • @Tasos, it works clean. That means I'm getting the full response. Also checked on `Postman` and it returned me `malformed JSON`. That might be the reason I'm unable to parse it. Thanks for the help. – Akeshwar Jha Feb 22 '16 at 05:47
  • @AkeshwarJha how you are able to parse it then ? i tried this solution and i got complete response in substring but sending substring for json parsing brings cannot be converted to jsonObject it means the break points is not recognized and and could not parse complete string . – Addi.Star Jan 22 '17 at 10:09
  • @Akeshwar Jha how can i append all the substring in on string and make parse complete – Addi.Star Jan 22 '17 at 10:10