首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

Android网络编程之经过Post方法实现

2012-08-21 
Android网络编程之通过Post方法实现public void MyFunction{ HttpClient httpclient new DefaultHttpCli

Android网络编程之通过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();

? }

}

?

http://www.winu.cn/space-859923-do-blog-id-97643.html

热点排行