我试图通过使HTTP请求,以更新的Android MySQL的数据,但它给了我一个错误类型不匹配:不能转换从org.apache.http.HttpResponse
“类型不匹配:不能从组织转变。 apache.http.HttpResponse到com.google.api.client.http.HttpResponse”
在此行的代码 “httpClient.execute(httpPost)”
HttpResponse response = httpClient.execute(httpPost);
,它给和选项来快速修复通过添加org.apache.http like
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;
}
烨。得到它了。谢谢 – user1781367
@nana:很高兴帮助。祝你好运。 – kosa