百度得知Android2.2以上使用getInputStream,需要加上
hc.setRequestProperty("Accept-Encoding", "identity");
可是试了下还是不行。。。
URL url = new URL(s);
HttpURLConnection hc = (HttpURLConnection)url.openConnection();
hc.setRequestMethod("GET");
hc.setDoInput(true);
hc.setUseCaches(false);
hc.setInstanceFollowRedirects(true);
hc.setRequestProperty("Accept-Encoding", "identity"); //加上
hc.setRequestProperty("Host", "api.yeelink.net");
hc.setRequestProperty("U-ApiKey", "4d968660ad88e84f2c66ee5723e60cf8");
hc.setRequestProperty("Content-Length", "0");
hc.setRequestProperty("Connection", "close");
hc.connect();
int streamLength = hc.getContentLength();