HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(URL);
try {
StringEntity documentStringified = new StringEntity(Obj.toString());
httpPost.setEntity(documentStringified);
} catch (UnsupportedEncodingException e) {
Log.d("UnsupportedEncodingException", e.toString());
}
try {
HttpResponse response = httpClient.execute(httpPost);
Log.d("Response", response.toString());
} catch (IOException e) {
Log.d("IOException", e.toString());
}
我無法獲得response
。如何在Logger or console.
response.toString()
或response.getEntity.toString()
中打印響應不起作用。獲取JSON響應Android
我應該如何設置內容類型爲"application/json"
。
and entity is nothing but response.getEntity()right? – Kevin
最後一個問題,我如何設置內容類型:'application/json'到我的http – Kevin
是的,實體是response.getEntity() –