【发布时间】:2016-09-29 05:24:16
【问题描述】:
这要在关键 Json 中发送 JsonObject。所以请告诉如何使用凌空发送它。 json={"product":"magie"}
如何在 Volley 中发送这些数据,我在下面添加了 asyncTask 代码,用于使用该类型数据的命中 api。
enter code here
protected void onPreExecute() {
if (progress)
GlobalAlerts.showProgressDialog(context);
}
@Override
protected String doInBackground(String... params) {
String resp = null;
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("product","magie");
} catch (JSONException e) {
e.printStackTrace();
}
String data = "json=" + jsonObject.toString();
String url ="http://anc.php";
resp = new JsonCall().executeHttpPostRequest(url, data);
return resp;
}
protected void onPostExecute(String resp) {
if (progress)
GlobalAlerts.hideProgressDialog();
if (resp != null) {
callback.onTaskComplete(resp);
} else {
GlobalAlerts.singleAlert((Activity) context, context.getString(R.string.warning), "Error", false);
}
}
【问题讨论】:
-
发布您的代码。
-
请检查simplifiedcoding.net/android-volley-post-request-tutorial 否则在此处发布您完成的一些代码
-
您可以在以下链接中找到答案:- [> stackoverflow.com/questions/24873718/…
-
见this
-
@Amol Patel 请发布您尝试过的内容,否则请在 Google 上搜索。使用 volley 的 json 解析器有很多例子
标签: java android json android-volley