try {
String URLName = "http://www.sample.com";
String line,res = "";
HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
while ((line = in.readLine()) != null){
res=res+line;
}
}
catch (Exception e) {
e.printStackTrace();
}
最后,我从朋友的 android 4.x 上的 res 中得到“”,但它在我的模拟器上运行良好,当我使用朋友手机上的浏览器打开网站时:www.sample.com 然后我的应用程序再次运行,直到我们重启手机