サーバーにデータを送信する必要があるアプリがあります。プロセスを処理する 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 を初めて使用し、エラーの原因がわかりません。どうもありがとう!