我今天将手机更新为Gingerbread(2.3.2)并启动了我开发的应用程序并发现它无法加载其数据.该应用程序在我从1.6到2.2测试的每个其他Android版本上运行正常,但随后在Gingerbread中出现了IOException.有人知道GZipInputStream或URL.openStream()中是否有变化吗?
InputStream in = null;
GZIPInputStream zin = null;
URL url = null;
try {
url = new URL("http://www.test.com/gzipped_data.gz");
in = url.openStream();
zin = new GZIPInputStream(in);
}
catch (MalformedURLException e) {
return false;
}
catch (IOException e) {
return false;
}
在1.6到2.2中,这段代码运行正常,在2.3中我得到一个IOException,其中包含有关魔术块不正确的消息.我假设openStream发生了一些变化,搞乱了MIME类型或者这个数据上的东西.我读了其他地方,openStream不是处理HTTP连接最可靠的方法,所以这可能是重写我的连接代码的一个很好的借口.