标签:
Get
String url = CommonInterfaceUrl.COMM_GetWorksDetailUrl + "/" + worksID; RequestQueue mQueue = Volley.newRequestQueue(MyApplication.mInstance .getApplicationContext()); StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() { @Override public void onResponse(String response) { }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { if (UtilsCheck.checkVolleyNewWork(error.getMessage())) { ToastUtils.showShort(R.string.not_network); } else { ToastUtils.showShort(R.string.not_get_data); } } }); mQueue.add(stringRequest);
Post
String url = CommonInterfaceUrl.COMM_SaveAttentionUrl; RequestQueue mQueue = Volley.newRequestQueue(MyApplication.mInstance .getApplicationContext()); StringRequest stringRequest = new StringRequest( Method.POST, url, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d("TAG", response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("TAG", error.getMessage(), error); } }) { @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> map = new HashMap<String, String>(); map.put("userName", "aaaa"); map.put("password", "bbbb"); return map; } }; mQueue.add(stringRequest);
标签:
原文地址:http://www.cnblogs.com/ruiati/p/4741718.html