【发布时间】:2019-03-28 08:53:43
【问题描述】:
我正在使用 Fast-Android-Networking,我想将数据发送到包含字符串和数组的服务器。可以发送字符串,但我无法发送数组而不是数组列表。这是简单的数组。 我已经搜索了其他解决方案,但都是关于凌空抽射。 谁能帮忙? 请不要标记重复。 最后 5 个参数是数组。我尝试将它作为 String.valueOf(ReadQuran) 但它也没有工作。
我的代码:
AndroidNetworking.post(Api.ROOT_URL +"api/stageFiveFormData")
.addBodyParameter("mto_id",idu)
.addBodyParameter("school_id", scholid)
.addBodyParameter("person_name", personnameS)
.addBodyParameter("designation", designantionS)
.addBodyParameter("cell_number",personcellS)
.addBodyParameter("email",emailpersonS)
.addBodyParameter("whatsapp_number",whatsApppersonS)
.addBodyParameter("school_name",schoolNameS)
.addBodyParameter("postal_address",postalAdressS)
.addBodyParameter("city",cityS)
.addBodyParameter("tehsil",tehsilS)
.addBodyParameter("district",districtS)
.addBodyParameter("s_primary", priamryChecked)
.addBodyParameter("s_middle", middleChecked)
.addBodyParameter("s_high", highChecked)
.addBodyParameter("s_higher", hsChecked)
.addBodyParameter("principal_name", nameOfPrincipalS)
.addBodyParameter("p_contact_num",cellNoPrincipalS)
.addBodyParameter("p_email",emailPrincipalS)
.addBodyParameter("p_whatsapp_number",whatsAppPrincipalS)
.addBodyParameter("class", Class)
.addBodyParameter("rq_book", String.valueOf(ReadQuran))
.addBodyParameter("rqb_qty", String.valueOf(ReadQuranQty))
.addBodyParameter("fq_book", String.valueOf(FehamQuran))
.addBodyParameter("fqb_qty", String.valueOf(FehamQuranQty))
.setPriority(Priority.HIGH)
.build()
.getAsString(new StringRequestListener() {
public void onResponse(String response) {
try {
JSONArray jsonArray = new JSONArray(response);
JSONObject jsonObject = jsonArray.getJSONObject(0);
String result = jsonObject.getString("result");
String message = jsonObject.getString("message");
if (result.equalsIgnoreCase("success")) {
Toast.makeText(FormStage5.this, "" + message, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(FormStage5.this, formstage2submittedmsg.class);
startActivity(intent);
pDialog.dismiss();
} else/* (result.equalsIgnoreCase("0"))*/ {
Toast.makeText(FormStage5.this, ""+message, Toast.LENGTH_SHORT).show();
pDialog.dismiss();
}
} catch (JSONException e) {
pDialog.dismiss();
Toast.makeText(FormStage5.this, "Something Went Wrong , Try Again", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onError(ANError anError) {
Toast.makeText(FormStage5.this, "Please Check Your Internet Connection" + anError.toString(), Toast.LENGTH_LONG).show();
pDialog.hide();
}
});
【问题讨论】: