【问题标题】:Not recieving any response from Volley没有收到 Volley 的任何回复
【发布时间】:2020-02-25 03:28:10
【问题描述】:

我几乎没有得到任何回应。

这是一个学校项目,我没有收到任何来自 volley 的回复,请帮忙。

我尝试了不同版本的 Volley,我尝试将互联网访问添加到清单中,但没有帮助。

        RequestQueue queue = Volley.newRequestQueue(this);
        api();



        public void api(){

        String new_url = "http://api.myjson.com/bins/kp9wz";



        System.out.println(new_url);

        final JsonObjectRequest request = new 
        JsonObjectRequest(Request.Method.GET, new_url, null, new 
        Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                try {
                    JSONArray jsonArray = response.getJSONArray("employees");
                    devices = new ArrayList<>();

                    for(int i = 0; i < jsonArray.length(); i++){
                        JSONObject jsonObject = jsonArray.getJSONObject(i);

                        String deviceId = jsonObject.getString("firstname");
                        String deviceName = jsonObject.getString("age");
                        String deviceStatus = jsonObject.getString("mail");


                        System.out.println(jsonObject.getString("firstname"));
                        System.out.println(jsonObject.getString("age"));
                        System.out.println(jsonObject.getString("mail"));

                        devices.add(new 
           Device(deviceName,deviceStatus,deviceId));
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
                System.out.println("WTF");
            }
             });
             }

´´´


I don't get anything
I expect it to save the data into the arraylist and sout, each field in the for loop

【问题讨论】:

    标签: android-studio android-volley


    【解决方案1】:

    我太笨了,没有向 RequestQueue 提出请求,我已经解决了。

    【讨论】:

      猜你喜欢
      • 2018-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-19
      • 1970-01-01
      • 2017-09-24
      • 1970-01-01
      • 2018-12-12
      相关资源
      最近更新 更多