排球 - 没有来自URL响应 [英] Volley - no response from the URL

查看:121
本文介绍了排球 - 没有来自URL响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从我现在用的排球击中库的URL任何回应,请你能帮助我吗?

我对我的模拟器得到这个 :com.android.volley.NoConnectionError:java.io.IOException异常:内容长度保证45个字节,但得到0。

我已经贴了code如下:

字符串URL = http://ipchicken.com

  JsonObjectRequest jsObjRequest =新JsonObjectRequest(
            Request.Method.POST,网址,空,
            新Response.Listener<的JSONObject>(){

                @覆盖
                公共无效onResponse(JSONObject的响应){
                    // TODO自动生成方法存根
                    sampletext.setText(响应=>中+ response.toString());


                }
            },新Response.ErrorListener(){

                @覆盖
                公共无效onErrorResponse(VolleyError错误){
                    // TODO自动生成方法存根
                    sampletext.setText(error.toString());

                }
            });

    queue.add(jsObjRequest);
 

解决方案

如果您构建了您的请求队列用手,而不是调用 Volley.newRequestQueue ,您需要调用。开始()就可以了。否则,它看起来很好。 谢谢

I am unable to get any response from the URL I am hitting using the Volley library, please can you help me out ?

I am getting this on my emulator : "com.android.volley.NoConnectionError:java.io.IOexception:content length promised 45 bytes, but received 0 ."

I have pasted the code below:

String url = "http://ipchicken.com"

    JsonObjectRequest jsObjRequest = new JsonObjectRequest(
            Request.Method.POST, url, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    // TODO Auto-generated method stub
                    sampletext.setText("Response => " + response.toString());


                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub
                    sampletext.setText( error.toString());

                }
            });

    queue.add(jsObjRequest);

解决方案

If you constructed your RequestQueue by hand, instead of calling Volley.newRequestQueue, you need to call .start() on it. Otherwise it looks fine. Thanks

这篇关于排球 - 没有来自URL响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆