try {
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet("http://app2.nea.gov.sg/anti-pollution-radiation-protection/air-pollution/psi/psi-readings-over-the-last-24-hours");
HttpResponse response;
response = client.execute(get);
Toast.makeText(MainActivity.this, "WAD", Toast.LENGTH_SHORT).show();
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line+"\n");
}
in.close();
charset = sb.toString();
tv.setText(charset);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在这一行中,
响应 = client.execute(get);
该程序似乎没有继续代码,它只是挂在那里并且什么都不做。
我已经声明了互联网权限,但我找不到它有什么问题?