【发布时间】:2013-11-16 09:38:28
【问题描述】:
我已经参考了这个... Android HttpClient, DefaultHttpClient, HttpPost 、http://www.androidsnippets.com/executing-a-http-post-request-with-httpclient 和 http://www.javacodegeeks.com/2013/06/android-apache-http-client.html 链接... 他们已经指定传递 url 而他们没有指定传递参数...... 当我实现上面网址中给出的代码时,我收到了这个错误......我是新手...... 我把这个方法称为...
public void postData() {
String res="";
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", ""));
nameValuePairs.add(new BasicNameValuePair("email", ""));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Log.e("response",""+response);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
请帮帮我... 谢谢..
【问题讨论】:
-
请分享你的代码和你得到的错误
-
感谢您的快速回复..我发布了我的代码..请看看..