80,351
社区成员
发帖
与我相关
我的任务
分享
try {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(DEFAULT_CONNECT_URI);
HttpResponse response = null;
HttpEntity entity = null;
UrlEncodedFormEntity entry = new UrlEncodedFormEntity(nameValuePairs);
post.setEntity(entry);
response = client.execute(post);
Log.i("Young", "Statue is " + response.getStatusLine().getStatusCode());
entity = response.getEntity();
result = EntityUtils.toString(entity);
} catch (Exception e) {
e.printStackTrace();
return null;
}
try {
JSONObject object = new JSONObject(result);
JSONArray valueList = object.getJSONArray("categories");
for(int i = 0; i < valueList.length(); i++){
String id = valueList.getJSONObject(i).getString("id");
String name = valueList.getJSONObject(i).getString("name");
infos.add(info);
}
} catch (JSONException e) {
e.printStackTrace();
}