0
我的應用連接到服務器,一旦服務器收到數據,它會發送一個哈希碼作爲響應...我的問題是如何獲得這個哈希碼?Android-從服務器獲取哈希碼
我用下面的代碼來發布數據:
try {
HttpClient client = new DefaultHttpClient();
String postURL = "http://somepostaddress.com";
HttpPost post = new HttpPost(postURL);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("user", "kris"));
params.add(new BasicNameValuePair("pass", "xyz"));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
Log.i("RESPONSE",EntityUtils.toString(resEntity));
}
} catch (Exception e) {
e.printStackTrace();
}
好的,但如何獲得哈希碼? – Dev
String hashCode = EntityUtils.toString(resEntity); – aromero
這假設你在迴應中以純文本的形式返回哈希碼或任何字符串。 – aromero