android http连接问题。编译不报错,真机运行闪退

public class MainActivity extends Activity {
private static String url="www.baidu.com";
private TextView a1 = null;
private HttpResponse httpResponse=null;

private HttpEntity httpEntity=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
a1 = (TextView) findViewById(R.id.textView);
getPDAServerData(url);
}

   /**
    * 请求服务
    * @param url
    */
   private void getPDAServerData(String url){
     // TODO Auto-generated method stub  
        //生成一个请求对象  
        HttpGet httpGet=new HttpGet("http://www.baidu.com");  
        //生成一个Http客户端对象  
        HttpClient httpClient=new DefaultHttpClient();  
        //使用Http客户端发送请求对象  
        InputStream inputStream=null;  
        try {  
            httpResponse=httpClient.execute(httpGet);  
            //收到服务器的响应之后把返回的数据读取出来  
            httpEntity=httpResponse.getEntity();  
            inputStream=httpEntity.getContent();  
            //流文件的读取  
            BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream));  
            String resultString="";  
            String lineString="";  
            while((lineString=reader.readLine())!=null){  
                resultString=resultString+lineString;  
            }  
            a1.setText(resultString);  
        } catch (ClientProtocolException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        } catch (IOException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        }  
        finally{  
            try {  
                inputStream.close();  
            } catch (Exception e2) {  
                // TODO: handle exception  
                e2.printStackTrace();  
            }  

}
}
}
错误日志
图片说明

抛出的异常名称是什么?
检查一下MainActivity.java 第45行

信息不全,应该还有错误信息,你打上几个断点,仔细调试一下

a1 = (TextView) findViewById(R.id.textView);
getPDAServerData(url); 
改成

a1 = (TextView) findViewById(R.id.textView);
new Thread(){
            public void run(){
                   getPDAServerData(url); 
            }
        }.start();

去百度吧,百度上或许会有。

你得把异常的名字那段也截出来,还有45行到底是哪一行

还要访问网络不要再主线程中,要在子线程中,通过handler+message的方式,在子线程中的请求网络,然后通过handler发送消息到主线程,在主线程中更新ui

lz,可以把日志复制粘贴出来的。你的截图信息不全阿。

耗时工作不能在主线程内执行,会发生ANR错误,需创建一个工作线程来执行操作,并通过handle去更新ui界面。