android发送HTTP请求代码,以GET方式发送。

android发送HTTP请求代码,以GET方式发送。
String uriAPI = “http://www.getideas.cn/service/service.do?me=1″;
                          HttpGet httpRequest = new HttpGet(uriAPI);
try
{
HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);
if (httpResponse.getStatusLine().getStatusCode() == 200)
{
                                              //TODO
}
else
{
Toast.makeText(this, “发送失败!”,Toast.LENGTH_SHORT);
}
}
catch (Exception e)
{
Toast.makeText(this, “发送失败!”,Toast.LENGTH_SHORT);
}

posted @ 2012-07-16 14:25  悬崖上的蒲公英  阅读(146)  评论(0)    收藏  举报