Android-从服务器获取哈希代码

Android-从服务器获取哈希代码,android,post,connection,Android,Post,Connection,我的应用程序连接到服务器,一旦服务器收到数据,它将发送一个哈希代码作为响应。。。我的问题是如何获取此哈希代码 我使用以下代码发布数据: try { HttpClient client = new DefaultHttpClient(); String postURL = "http://somepostaddress.com"; HttpPost post = new HttpPost(postURL); List<NameValuePair

我的应用程序连接到服务器,一旦服务器收到数据,它将发送一个哈希代码作为响应。。。我的问题是如何获取此哈希代码

我使用以下代码发布数据:

 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();
}
试试看{
HttpClient=new DefaultHttpClient();
字符串姿势=”http://somepostaddress.com";
HttpPost=新的HttpPost(postrl);
List params=new ArrayList();
添加参数(新的BasicNameValuePair(“用户”、“克里斯”);
添加参数(新的BasicNameValuePair(“通过”、“xyz”);
UrlEncodedFormEntity ent=新的UrlEncodedFormEntity(params,HTTP.UTF_8);
邮政实体(ent);
HttpResponse responsePOST=client.execute(post);
HttpEntity当前状态=responsePOST.getEntity();
如果(最近性!=null){
Log.i(“响应”,EntityUtils.toString(resEntity));
}
}捕获(例外e){
e、 printStackTrace();
}
使用,这将以
字符串的形式返回响应

URL url = new URL(url_str);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
InputStream stream = connection.getInputStream();

这就是我为GET所做的,它应该也适用于POST

字符串hashCode=EntityUtils.toString(最近性);这假设您在响应中以纯文本形式返回哈希代码或任何字符串。然后,您的请求中缺少某些内容,即web服务器返回的响应。