Android Volley Library doen't return whole response data

我与影子孤独终老i 提交于 2019-12-03 17:15:15

It's not the problem with Volley!, it's the problem(limitation) of logcat for displaying limited size of data. (I'm assuming you are reading the response in logcat from your code)

if you are using eclipse here is the solution

 public void BoardRoomRequest() {
            pdialog = new ProgressDialog(BoardRoom.this);
            pdialog.setTitle("Please wait....");
            String url = Global_Application.url + "views/boardroom";
            Log.d("url========", url);
            Map<String, String> params = new HashMap<String, String>();
            StringRequest req = new StringRequest(Request.Method.GET,
                    getApplicationContext(), url, params,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            // TODO Auto-generated method stub

                       // Log.d("Response", response);  //can't display more data

                    //=========================
                    longInfo(response); //solution for displaying more data in logcat
                    //=========================

                            pdialog.dismiss();
                        }
                    }, new ErrorListener() {

                        @Override
                        public void onErrorResponse(VolleyError error) {
                            // TODO Auto-generated method stub
                            Log.d("Error.Response", error.toString());
                            pdialog.dismiss();
                        }
                    });

            queue.add(req);
            pdialog.show();
        }   

public void longInfo(String str) {
            if(str.length() > 4000) {
                Log.i("",str.substring(0, 4000));
                longInfo(str.substring(4000));
            } else
                Log.i("",str);
        } 

Note: $ adb logcat -g ring buffer is 64Kb (63Kb consumed), max entry is 4096b, max payload is 4076b

LogCat is very much device dependent. The size and also the handling of bad character differs between different handsets.

Give it try for this also:

     import java.util.*;

        class Test
        {
        public static void main(String[] args)
        {
        System.out.println(Arrays.toString(
        "Thequickbrownfoxjumps".split("(?<=\\G.{4})")
        ));
        }
        }

output: [Theq, uick, brow, nfox, jump, s]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!