我想检查我是否已使用 httppost 方法成功将数据发布到 web 服务。如何验证数据是否发布成功?如何检查 json.put("URL".getpref()); 是否已成功发布到 web 服务?
HttpPost post = new HttpPost(url1);
try {
json.put("URL", getPref());
Log.i("json Object", json.toString());
StringEntity stringEntity = new StringEntity(json.toString());
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
post.setEntity(stringEntity);
//ResponseHandler responseHandler = new BasicResponseHandler();
response = client.execute(post);
Log.e("RESPONSE", response.toString());
String responseBody = EntityUtils
toString(response.getEntity());
System.out.println(responseBody);