`
ET焖猪仔
  • 浏览: 233840 次
  • 性别: Icon_minigender_1
  • 来自: 广东
社区版块
存档分类
最新评论

Android发送HTTP POST请求示范

阅读更多
public void MyFunction{

HttpClient httpclient = new DefaultHttpClient();

//你的URL

  HttpPost httppost = new HttpPost("http://www.winu.cn/post_datas.php");

 

  try {

   List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);

//Your DATA

   nameValuePairs.add(new BasicNameValuePair("id", "12345"));

   nameValuePairs.add(new BasicNameValuePair("stringdata", "eoeAndroid.com is Cool!"));

 

   httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

 

   HttpResponse response;

   response=httpclient.execute(httppost);

  } catch (ClientProtocolException e) {

   // TODO Auto-generated catch block

   e.printStackTrace();

  } catch (IOException e) {

   // TODO Auto-generated catch block

   e.printStackTrace();

  }

} 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics