我是Android的新手,我正在尝试对我的用户进行google +验证。当我尝试使用UrlEncodedFormEntity()时,它说“构造函数UrlEncodedFormEntity(ArrayList [])未定义”。下面是代码,我不知道如何摆脱这个错误。
公共类Posting扩展了AsyncTask,Void,Void> {
@Override
protected Void doInBackground(ArrayList<NameValuePair>... nameValuePair) {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("accounts.google.com");
// Url Encoding the POST parameters
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
// writing error to Log
e.printStackTrace();
}
// Making HTTP Request
try {
HttpResponse response = httpClient.execute(httpPost);
// writing response to log
Log.d("Http Response:", response.toString());
} catch (ClientProtocolException e) {
// writing exception to log
e.printStackTrace();
} catch (IOException e) {
// writing exception to log
e.printStackTrace();
}
return null;
}
}