http协议实例
1. 通过 GET 请求获取数据
?
?
?
2. 获取网上图片并转换格式
?
?
?
3. 通过 POST 提交数据
?
?
public void MyFunction{HttpClient httpclient = new DefaultHttpClient();// 你的 URLHttpPost httppost = new HttpPost("http://www.eoeandroid.com/post_datas.php");try {List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);//Your DATAnameValuePairs.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 blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}??
?