码迷,mamicode.com
首页 > 其他好文 > 详细

Volley Get Post 方法

时间:2015-08-19 13:08:48      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

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);

  

Volley Get Post 方法

标签:

原文地址:http://www.cnblogs.com/ruiati/p/4741718.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!