zoukankan      html  css  js  c++  java
  • Volley Get Post 方法

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

      

  • 相关阅读:
    C++之Static与Const
    LInux主机与虚拟机网络链接
    C#数据类型与数据类型转化
    C#网编Console(二)
    C#网编Winform(三)
    C#网编基础类与API(一)
    C实现CPU大小端判断
    QT程序图标设置
    四、初识Socket套接字API
    C++之继承(二)
  • 原文地址:https://www.cnblogs.com/ruiati/p/4741718.html
Copyright © 2011-2022 走看看