下面这段代码在Service中运行和在Activity中运行得到的长度为什么会不同
HttpClient httpClient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost(HttpUrlUtil.WEBSERVER_PATH+downloadPath);
httpResponse=httpClient.execute(httpPost);
HttpEntity httpEntity=httpResponse.getEntity();
BufferedHttpEntity bufferedHttpEntity = new BufferedHttpEntity(httpEntity);
System.out.println(httpResponse.getStatusLine().toString());
System.out.println("bufferedHttpEntity"+bufferedHttpEntity.getContentLength());
在Service onStartCommand中运行返回的bufferedHttpEntity.getContentLength()一直都是6277,httpResponse.getStatusLine().toString()返回的是200
response.getStatusLine().getStatusCode()==200链接成功,你打印的应该是这个吧
httpResponse.getStatusLine().toString()这不是返回长度,而是标识码,200就是连接成功了。