Android 网络请求框架AsyncHttpClient
Android 中网络请求框架有很多,我现在使用的YoLanda大神写的Nohttp
封装的特别好,AsyncHttpClient是一个很老的框架,似乎没人更新维护了,但是依然很强大,网上对于他的介绍也非常多在里这我就不做讲解了,今天主要讲一下AsyncHttpClient 如何post json数据
JSONObject jsonObject = new JSONObject();
jsonObject.put("parameter_fist", "test_1");
jsonObject.put("parameter_second", "test_2");
StringEntity entity = new StringEntity(jsonObject.toString());
AsyncHttpClient client = new AsyncHttpClient();
client.post(MainActivity.this, urlString, entity, "application/json",
new JsonHttpResponseHandler() {
//成功或失败的代码
}
以上是post JsonObject 如果post JsonArray该如何处理我想大家应该明白了!