【发布时间】:2018-04-16 14:43:40
【问题描述】:
我正在做一个 android 应用程序,我正在尝试为 Web 服务器实现 JSON 请求。我正在使用库:android-async-http-1.4.6.jar。 我写了以下代码:
public void RequestToServer() {
try {
AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
// params.put("uid", User_id.toString());
JSONObject cred = new JSONObject();
cred.put("user",LoginActivity.m_user);
cred.put("pwd", LoginActivity.m_pwd);
Calendar c = Calendar.getInstance();
cred.put("anno", Integer.toString(c.get(Calendar.YEAR)));
StringEntity entity = new StringEntity(cred.toString());
client.post(this, "http://vdctest.agrishare.com/list_up", entity, "application/json",responseHandler);
}catch(Exception e)
{
}
}
但是我对 client.post 中的语音 responseeHandler 弄错了,我无法弄清楚问题是什么?谁能帮我? 提前感谢您的帮助。
【问题讨论】:
-
发生了什么或没有发生什么?此外,空的 catch 块也不是一个好主意,因为您只是在默默地捕获可能会告诉您问题的错误
-
“误以为语音 responseeHandler”.. 这是什么意思?您的响应处理程序是否被调用?您是否认识到您正在调用的 url 正在返回 404?
-
我无法填写代码,因为我弄错了responseHandler。我不明白是否缺少某些课程。
-
抱歉,再次不确定:您无法编译和运行您的代码,对吗?
标签: android json web-services