当前位置:编程学习 > JAVA >>

android 这是什么异常啊。

 代码 public void doGet()
    {
     Log.w(tag, "25222222");
    
     //新建URL
     String url = "http://www.baidu.com";
     //新建GET型的请求
     HttpGet httpRequest = new HttpGet(url);
     //新建HTTP客户端
     Log.w(tag, "25222222");
     HttpClient httpClient = new DefaultHttpClient();
     try
{
     //执行请求返回结果
     Log.w(tag, "252222223");
HttpResponse httpResponse = httpClient.execute(httpRequest);
//判断结果状态
Log.w(tag, "25222221");
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
//得到结果内容
String result = EntityUtils.toString(httpResponse.getEntity());
//对结果内容进行处理。。。。
date.setText(result);
}
else
{
date.setText("应答错误:"+httpResponse.getStatusLine().toString());
}

}
catch (ClientProtocolException e)
{
// 客户端协议异常
e.printStackTrace();
}
catch (IOException e)
{
// IO异常
e.printStackTrace();
}
         
    }


--------------------编程问答-------------------- --------------------编程问答-------------------- 也加了internet权限
补充:Java ,  Eclipse
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,