我有一个需要向服务器发送一些数据的应用程序。我创建了一个 Connection 类来处理这个过程。下面是我的代码:
private class Connection extends AsyncTask<ArrayList<NameValuePair>, Void, Void>{
protected Void doInBackground(ArrayList<NameValuePair>... nameValuePairs){
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.xxxx.com/postdata.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Log.i("postData", response.getStatusLine().toString());
}
finally{}
}
}
但是,我收到以下错误:“构造函数 UrlEncodedFormEntity(ArrayList[]) 未定义”。我是 Android 新手,我不知道是什么导致了错误。非常感谢!