Volley : "参数param:{ inoutNo:inoutNo ,whcode:’’}
Posted 碎冰
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Volley : "参数param:{ inoutNo:inoutNo ,whcode:’’}相关的知识,希望对你有一定的参考价值。
private void fuzzySearch() {
mRequestQueue = Volley.newRequestQueue(getActivity());
String str = SharedPreUtil.getString(getActivity(), SharedPreUtil.KEY_URI);
IPPORT ip = JsonTools.parseJsonToBean(str, IPPORT.class);
String url = "http://" + ip.uriArray.get(0).ip + ":" + ip.uriArray.get(0).port + Url.OUTFUZZYSEARCH;
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("inoutNo", inOutNo.getText().toString().toLowerCase());
if (TextUtils.isEmpty(whCode.getText().toString())) {
jsonObject.put("whcode", "null");
}
} catch (JSONException e) {
e.printStackTrace();
}
LogUtil.e(TAG, inOutNo.getText().toString().toLowerCase());
LogUtil.e(TAG, jsonObject.toString());
mRequestQueue.cancelAll(TAG);
jsonRequest = new JsonObjectRequest(Request.Method.POST, url, jsonObject, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
LogUtil.e("!!!ok", jsonObject.toString());
//jsonObject.get("");
fuzzySearchData = JsonTools.parseJsonToBean(jsonObject.toString(), IOCOutMakeMaterialFuzzySearch.class);
if (fuzzySearchData.data == null) {
Log.e("msg", "msg zps");
} else {
for (int i = 0; i < fuzzySearchData.data.size(); i++) {
autoStrings.add(fuzzySearchData.data.get(i).pi_inoutno);
}
autoStringAdapter.notifyDataSetChanged();
}
loadingView.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
LogUtil.e("!!!err", new String(volleyError.networkResponse.data));
ErrorMsg errorMsg = JsonTools.parseJsonToBean(new String(volleyError.networkResponse.data), ErrorMsg.class);
Toast.makeText(getActivity().getApplicationContext(), errorMsg.exceptionInfo, Toast.LENGTH_LONG).show();
reset();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return VolleyUtil.getVolleyUtil().setCookies();
}
};
jsonRequest.setTag(TAG);
mRequestQueue.add(jsonRequest);
}
以上是关于Volley : "参数param:{ inoutNo:inoutNo ,whcode:’’}的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Volley 的 POST 请求中将整数作为参数传递?
Volley的GetPost方式(JsonObjectRequestStringRequest)以及Volley获取图片的3种方式