• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
lamber
博客园    首页    新随笔       管理    订阅  订阅

Android 之 Http-get

 

 

public void get() {
  String url = httpUrl + "?text1=" + text1.getText().toString()
  + "&text2=" + text2.getText().toString();
  // 创建HttpGet对象
  HttpGet request = new HttpGet(url);
  // 创建HttpClient对象
  HttpClient client = new DefaultHttpClient();
  HttpResponse httpResponse = null;
  try {
  httpResponse = client.execute(request);
  if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
  text3.setText(EntityUtils.toString(httpResponse.getEntity(),
  "utf-8"));
  }
  } catch (ClientProtocolException e) {
  e.printStackTrace();
  } catch (IOException e) {
  e.printStackTrace();
  }
  }
想要获得成功,首先要自己相信自己,再者要赢得周围朋友的信任!
posted @ 2011-07-17 21:28  android5k  阅读(302)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3