写了个方法,实现的登录功能,代码是参照的书上源码,但不懂具体的意思,哪位大侠能帮忙解释下。
 private void httpPost() {
  String URL = "**********";
  String strUserName = userName.getText().toString();
  String strPassword = password.getText().toString();  HttpPost httpRequest = new HttpPost(URL);
  HttpResponse httpResponse = null;
  List<NameValuePair> params = new ArrayList<NameValuePair>();
  params.add(new BasicNameValuePair("userName", strUserName));
  params.add(new BasicNameValuePair("password", strPassword));
  params.add(new BasicNameValuePair("flag", "0"));
  
  try {
   httpRequest.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); 
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }  try {
   httpResponse = new DefaultHttpClient().execute(httpRequest); 
  } catch (ClientProtocolException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  
  if(httpResponse.getStatusLine().getStatusCode() == 200) {
   byte[] data = new byte[2048];
   try {
    data = EntityUtils.toByteArray( (HttpEntity)httpResponse.getEntity());
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);
   } catch (IOException e) {
    e.printStackTrace();
   }
//   user = new String(dis.readUTF());
  }
  
 }
书上说,到此手机终端从Web服务器获取了所有类型的数据。请问源码中具体是那部分获得了服务器返回的数据啊,我好整理了加载到Activity,感激不尽啊!
服务器web服务urlandroid  HttpPost