我正在尝试通过发出 HTTP 请求来更新 Android 中的 MySQL 数据,但它给了我一个错误
“类型不匹配:无法从 org.apache.http.HttpResponse 转换为 com.google.api.client.http.HttpResponse”
在这行代码“httpClient.execute(httpPost)”
HttpResponse response = httpClient.execute(httpPost);
它通过添加 org.apache.http 来提供快速修复的选项
org.apache.http.HttpResponse response = httpClient.execute(httpPost);
有人可以告诉我我在这里做错了什么吗?太感谢了!
protected String doInBackground(String... params) {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://---.com/---/approve_request.php");
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("status", "Approved"));
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
org.apache.http.HttpResponse response = httpClient.execute(httpPost);
Log.d("Http Response:", response.toString());
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}