new Thread(){
@Override
public void run() {
String path=”http://m.weather.com.cn/atad/101010100.html”;
try{
URL url=new URL(path);
HttpURLConnection con=(HttpURLConnection)url.openConnection();
con.setConnectTimeout(5000);
con.setRequestMethod(“GET”);
if(con.getResponseCode()==200){
InputStream input=con.getInputStream();
Message msg=new Message();
msg.what=1;
msg.obj=input;
handler.sendMessage(msg);
}
}catch(Exception e){
Log.i(“error”,”exception”);
}
}
}.start();
}
程序运行到if(con.getResponseCode()==200)就会出现异常,把if判断去掉后InputStream input=con.getInputStream();也会出现异常,已经在配置文件中添加了权限,请问哪里出了问题?
这是logcat
10-03 09:47:38.878: I/Choreographer(6447): Skipped 60 frames! The application may be doing too much work on its main thread.
10-03 09:47:39.128: D/gralloc_goldfish(6447): Emulator without GPU emulation detected.
10-03 09:48:18.688: I/error(6447): exception
这样试试
new Thread(new Runnable() {
@Override
public void run() {
}
}.start();