Detailed explanations and examples of Volley in Android development
Recently, when I was working on projects, I have various gets and posts. It's crazy. I don't know anything like this, so I don't know what to do. Then Baidu took a look and found that I can use volley to request and obtain networks. Let's introduce the usage of volley below.
There are three ways to volley:JsonObjectRequest,JsonArrayRequest,StringRequest. In fact, it's almost the same, it's OK to learn from one example and learn from it. Here I will talk about JsonObjectRequest.
The method is as follows:
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(,null,Listener,ErrListener);
Examples are as follows:
RequestQueue myQueue = (getContext()); Map<String, String> params = new HashMap<String, String>(); ("dataStr", "2016/3/18"); ("selectRow", "0"); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(, url, new JSONObject(params),new <JSONObject>() { public void onResponse(JSONObject jsonObject) { try { (("data").getString("CreateTime")); (("data").getString("Title")); } catch (Exception e) { (); } } }, new () { public void onErrorResponse(VolleyError volleyError) { ("error", volleyError + ""); } }) ; ("tag"); (jsonObjectRequest);
This will solve it. . I can say that because of this, I have been busy on Friday afternoon until now... Okay, you can try to solve your current problem.
Thank you for reading, I hope it can help you. Thank you for your support for this site!