volly post请求

public void qq() {
			RequestQueue requestQueue = Volley.newRequestQueue(ForresultActivity.this);
			 StringRequest stringRequest = new StringRequest(Request.Method.POST,"http://www.cvbaoli.com/demo/rest/app/2.0/merchants/2388/checklists/33/files/1458287905442.jpg",
			     new Response.Listener<String>() {
			         @Override
			         public void onResponse(String response) {
			             Log.e("TAG上传资料", "response -> " + response);
			             handler.resultMap= new Gson().fromJson(response,Map.class);
						 MyApplication.getApplication().setHandler(handler); 
			             handler.sendEmptyMessage(CMessage.NET_MSG_UPLOADFILE);
			         }
			     }, new Response.ErrorListener() {
			         @Override
			         public void onErrorResponse(VolleyError error) {
			             Log.e("TAG", error.getMessage(), error);
			         }
			     }) {
				 
			     @Override
			     protected Map<String, String> getParams() throws AuthFailureError{
			         //在这里设置需要post的参数
			             Map<String, String> map = new HashMap<String, String>();  
			             map.put("name1", "value1");  
			             map.put("name2", "value2");  
			           return super.getParams();
			     }
			 };        
			 requestQueue.add(stringRequest);
	 }

你可能感兴趣的:(post请求,Volly)