private void volleypost_scom(final String com,final String ph, final String session) { RequestQueue requestQueue = Volley.newRequestQueue(this); Mapparams = new HashMap(); params.put("ModuleName", "User"); params.put("MethodName", "AddFeedBook"); params.put("Session", session); params.put("UserTel", ph); JSONArray ja = new JSONArray(); ja.put(com); params.put("Data", ja); JsonObjectRequest newMissRequest = new JsonObjectRequest( Request.Method.POST, "http://xxxxx", new JSONObject(params), new Response.Listener() {
@Override
public void onResponse(JSONObject jsonobj) {
System.out.println(jsonobj.toString());
try {
String status = jsonobj.getInt("Status") + "";
if (status.equals("0")) {
Toast.makeText(Percen_yijian.this, "感谢您的反馈,我们稍后进行处理", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (error.toString().equals("com.android.volley.TimeoutError"))
volleypost_scom(com,ph,session);
}
});
requestQueue.add(newMissRequest);
}
结构:
JSONArray ja = new JSONArray();
// JSONObject param1=new JSONObject();
// param1.put("13737042137", "11");
// param1.put("13737042135", "12");
// param1.put("13737042136", "13");//字符串数组字符串
for (int i = 0; i < SourceDateList.size(); i++) {
JSONObject param1 = new JSONObject();
param1.put(SourceDateList.get(i).getPhonenum().toString().replace("-", "").replace(" ", ""), SourceDateList.get(i).getName().toString());
ja.put(param1);//字符串数组
}
// ja.put(param1);
params.put("Data", ja);
网友评论