volley Demo

3866 단어 Volley

1
          sonikk csdn  http://blog.csdn.net/sonikk/article/details/9228481     sonikk    !

      ZXing-2.3.0

            :

android ——    Android     

android-integration ——    QR            

androidtest ——    Android       ,        android          

core ——      

          。。。

   :

   android        Eclipse

  :com.google.zxing.client.android

     :CaptureActivity

   :

      :

      -> Properties -> Java Build Path -> Source -> Link Source... ->  browse..  

  ZXing-2.3.0\core\src\main\java      ,  core

  ZXing-2.3.0\android-integration\src\main\java      ,  android-integration

(        ,         ,               


2
   jar,  libs    ,          ,           
(    Get  ,    www.baidu.com)

void test(){
URLUserLogin = "http://192.168.100.119:83/api/ERPUser/UserLogin";
		RequestQueue requestQueue = Volley.newRequestQueue(this);

		JSONObject param = new JSONObject();
		try {
			param.put("APIKey", "1");
			param.put("CompanyID", "");
			param.put("UserCode", "hkh01");
			param.put("UserPassword", "1");
			param.put("IMEI", "1");
		} catch (JSONException e) {
			e.printStackTrace();
		}

		JsonObjectRequest jsonOR = new JsonObjectRequest(Method.POST,
				URLUserLogin, param, new Listener<JSONObject>() {
					public void onResponse(JSONObject obj) {
						System.out.println("==Success:" + obj.toString());
					}
				}, new ErrorListener() {
					public void onErrorResponse(VolleyError error) {
						String msg = "==Error1==" + error.toString();
						System.out.println(msg);
					}
				});

		requestQueue.add(jsonOR);

		requestQueue.start();
	}

	// StringRequest sr = new StringRequest(Method.POST, URLUserLogin,
	// new Response.Listener<String>() {
	// public void onResponse(String response) {
	// String msg = "==Success:" + response;
	// vTest.setText(msg);
	// System.out.println(msg);
	// }
	// }, new Response.ErrorListener() {
	// public void onErrorResponse(VolleyError error) {
	// String msg = "==Error1==" + error.toString();
	// // + "==Error2==" + error.getCause()
	// // + "==Error3==" + error.getMessage();
	// vTest.setText(msg);
	// System.out.println(msg);
	// System.out.println("==Error2==" + error.getCause());
	// System.out.println("==Error3==" + error.getMessage());
	// }
	// }) {
	// @Override
	// protected Map<String, String> getParams() {
	// Map<String, String> params = new HashMap<String, String>();
	// params.put("APIKey", "1");
	// params.put("CompanyID", "1");
	// params.put("UserCode", "1");
	// params.put("UserPassword", "1");
	// params.put("IMEI", "1");
	//
	// return params;
	// }
	//
	// @Override
	// public Map<String, String> getHeaders() throws AuthFailureError {
	// Map<String, String> params = new HashMap<String, String>();
	// params.put("Content-Type", "application/json");
	// params.put("charset", HTTP.UTF_8);
	// params.put("Accept", "application/json");
	// return params;
	// }
	// };
	// requestQueue.add(sr);


좋은 웹페이지 즐겨찾기