问题描述
排球库不会返回整个响应数据。它只返回响应数据的一部分。我打电话Drupal的服务。下面是我的code吧。
公共无效BoardRoomRequest(){
pdialog =新ProgressDialog(BoardRoom.this);
pdialog.setTitle(请稍候......);
字符串URL = Global_Application.url +意见/会议室;
Log.d(URL ========,URL);
地图<字符串,字符串> PARAMS =新的HashMap<字符串,字符串>();
StringRequest REQ =新StringRequest(Request.Method.GET,
getApplicationContext(),URL,参数,可以
新Response.Listener<串GT;(){ @覆盖
公共无效onResponse(字符串响应){
// TODO自动生成方法存根
Log.d(响应,响应); pdialog.dismiss();
}
},新ErrorListener(){ @覆盖
公共无效onErrorResponse(VolleyError错误){
// TODO自动生成方法存根
Log.d(Error.Response,error.toString());
pdialog.dismiss();
}
}); queue.add(REQ);
pdialog.show();
}
这不是抽射问题!这是logcat的用于显示数据的大小限制的问题(限制)。 (我假设你正在阅读从code在logcat的响应)
如果你在这里使用eclipse是解决方案
公共无效BoardRoomRequest(){
pdialog =新ProgressDialog(BoardRoom.this);
pdialog.setTitle(请稍候......);
字符串URL = Global_Application.url +意见/会议室;
Log.d(URL ========,URL);
地图<字符串,字符串> PARAMS =新的HashMap<字符串,字符串>();
StringRequest REQ =新StringRequest(Request.Method.GET,
getApplicationContext(),URL,参数,可以
新Response.Listener<串GT;(){ @覆盖
公共无效onResponse(字符串响应){
// TODO自动生成方法存根 // Log.d(响应,响应); //不能显示更多的数据 // =========================
longInfo(响应); //显示在logcat中更多的数据解决方案
// ========================= pdialog.dismiss();
}
},新ErrorListener(){ @覆盖
公共无效onErrorResponse(VolleyError错误){
// TODO自动生成方法存根
Log.d(Error.Response,error.toString());
pdialog.dismiss();
}
}); queue.add(REQ);
pdialog.show();
}公共无效longInfo(字符串str){
如果(str.length()> 4000){
Log.i(,str.substring(0,4000));
longInfo(str.substring(4000));
}其他
Log.i(,STR);
}
注意: $亚行logcat -g
环形缓冲区为64KB(63KB消耗),最大项是4096b,最大有效载荷为4076b
LogCat中是非常多的设备相关。大小也是人品不好的处理不同手机之间的区别。
给它尝试,这也:
进口的java.util。*; 类测试
{
公共静态无效的主要(字串[] args)
{
的System.out.println(Arrays.toString(
Thequickbrownfoxjumps.split((小于?= \\\\ G. {4})。)
));
}
}输出:[Theq,uick,眉骨,nfox,跳跃,S]
Volley library doesn't return whole response data. It only return the part of the response data. I am calling drupal services. Below is my code for it.
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);
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();
}
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 -gring 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]
这篇关于Android的凌空图书馆doen't返回整个响应数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!