【问题标题】:com.android.volley.NoConnectionError: java.net.ProtocolException: Unexpected status line: HTTP/1.1 401.3 Unauthorizedcom.android.volley.NoConnectionError:java.net.ProtocolException:意外状态行:HTTP/1.1 401.3 Unauthorized
【发布时间】:2015-09-09 11:22:40
【问题描述】:

以下是我的代码。我得到了 com.android.volley.NoConnectionError: java.net.ProtocolException: Unexpected status line: HTTP/1.1 401.3 Unauthorized。

    RequestQueue queue = Volley.newRequestQueue(this);
    String url = "http://echo.jsontest.com/key/value/one/two";

    JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, (String)null,
            new Response.Listener<JSONObject>()
            {
                @Override
                public void onResponse(JSONObject response) {
                    Log.e("LOG_VOLLEY","response : "+response.toString());
                    System.out.println(response);
                    txt.setText("response : "+response.toString());
                }
            },
            new Response.ErrorListener()
            {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.e("LOG_VOLLEY", "Error : " + error.toString());
                    System.out.println(error);
                    txt.setText("Error : " +error.toString());
                }
            } );

    queue.add(getRequest);

}

我在使用 loopj 库时遇到了类似的错误。 这是我第一次使用 volley 库和 http 连接。 我感谢您的帮助。谢谢。

【问题讨论】:

    标签: android-volley protocolexception


    【解决方案1】:

    我使用了你的代码(删除了与TextView相关的代码行)并得到了如下截图(注意logcat窗口)

    【讨论】:

    • 你的应用怎么样?是否得到了预期的响应?
    • 哦!非常感谢!!!!我的手机出现错误..我的测试手机有问题.........
    • 好的,换个手机或者模拟器试试。祝你好运:-)
    • 感谢您的帮助谢谢:)
    猜你喜欢
    • 2016-11-13
    • 2016-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-12
    • 2019-05-03
    相关资源
    最近更新 更多