0

以下是我的代码。我得到了 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 连接。我感谢您的帮助。谢谢你。

4

1 回答 1

1

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

凌空获取请求

于 2015-09-09T14:36:27.753 回答