Android 如何在logcat中显示我的URL地址(HttpPost)?
我有一个登录屏幕,当用户点击登录按钮时,我需要向URL地址添加一些信息。这是我过去数据的代码:Android 如何在logcat中显示我的URL地址(HttpPost)?,android,http-post,tostring,logcat,Android,Http Post,Tostring,Logcat,我有一个登录屏幕,当用户点击登录按钮时,我需要向URL地址添加一些信息。这是我过去数据的代码: private String postData() { HttpClient httpClient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(PropertyManager.getLoginURL()); List<NameValuePair> nameValuePairs = new
private String postData() {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(PropertyManager.getLoginURL());
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
nameValuePairs.add(new BasicNameValuePair("u", Uri.encode(PropertyManager.getUserId())));
nameValuePairs.add(new BasicNameValuePair("p", Encryption.encrypt(PropertyManager.getPassword())));
nameValuePairs.add(new BasicNameValuePair("v", PropertyManager.VER));
nameValuePairs.add(new BasicNameValuePair("t", "0"));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httppost);
String responseBody = EntityUtils.toString(response.getEntity());
Log.i("Server Response 1: ", responseBody);
if (response.containsHeader("Set-Cookie")) {
PropertyManager.setSessionID(extractSessionId(response.getHeaders("Set-Cookie")[0].getValue()));
}
return responseBody;
} catch(UnsupportedEncodingException usee) {
usee.printStackTrace();
} catch(ClientProtocolException cpe) {
cpe.printStackTrace();
} catch(IOException ioe) {
ioe.printStackTrace();
}
return null;
}
但是,我只能看到我的URL,没有任何nameValuePairs参数。
如有任何建议,将不胜感激 尝试使用Log.i(“Requestd Connection”,httpPost.getEntity().toString());试试看这里:@M Mohsin Naeem,谢谢你的建议,但它显示的日志猫是:org.apache.http.client.entity。UrlEncodedFormEntity@2c1be020这不是我要找的东西。@Quintin Balsdon:我没有发现它与我的问题有关。请尝试使用Log.i(“Requestd Connection”,httpPost.getEntity().toString());试试看这里:@M Mohsin Naeem,谢谢你的建议,但它显示的日志猫是:org.apache.http.client.entity。UrlEncodedFormEntity@2c1be020这不是我要找的东西。@Quintin Balsdon:我觉得这与我的问题无关。
Log.i("Requestd Connection", httppost.getURI().toString());