【发布时间】:2010-01-14 10:03:20
【问题描述】:
我正在使用 httprequest 从 web 服务中检索数据,我知道使用 tomcat 我们可以使用 gunzip 算法压缩响应数据。
但是如何解压缩数据以显示,解压缩是否耗时?有没有其他方法可以在android上压缩响应和解压缩???
【问题讨论】:
标签: android compression response httprequest
我正在使用 httprequest 从 web 服务中检索数据,我知道使用 tomcat 我们可以使用 gunzip 算法压缩响应数据。
但是如何解压缩数据以显示,解压缩是否耗时?有没有其他方法可以在android上压缩响应和解压缩???
【问题讨论】:
标签: android compression response httprequest
有an example on the Apache website showing how to do gzip decompression with HTTPRequest and DefaultHTTPClient。 (您可以找到HTTPClient 示例here 的完整列表。)
至于耗时多长,找出数据的最佳方法是分析应用中处理压缩和未压缩数据的情况。使用the traceview tool 很容易做到这一点。
【讨论】:
DefaultHttpClient 编写了一个类,它会自动接受并解压缩gzipped 响应,而无需我做任何特别的事情。那是在 PC 上,但我不明白为什么 Android 上的行为会有所不同。