东东坏小子 2017-01-03 07:27 采纳率: 0%
浏览 1029

android Service网络下载视频

下面这段代码在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

  • 写回答

2条回答 默认 最新

  • 这个名有人用不 2017-01-03 08:07
    关注

    response.getStatusLine().getStatusCode()==200链接成功,你打印的应该是这个吧

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置