gpt4 book ai didi

android - 包 org.apache.http 不存在 sdk 23

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:18:42 28 4
gpt4 key购买 nike

<分区>

我升级到最新的 sdk 版本 23。现在我的一些代码不再工作了。这是我之前获得 json 的类(class):

public class Spots_tab1_json {
static String response = null;
public final static int GET = 1;
public final static int POST = 2;

public Spots_tab1_json() {

}
public String makeServiceCall(String url, int method) {
return this.makeServiceCall(url, method, null);
}
public String makeServiceCall(String url, int method,
List<NameValuePair> params) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
if (method == POST) {
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Cache-Control", "no-cache");
if (params != null) {
httpPost.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));
}
httpResponse = httpClient.execute(httpPost);
} else if (method == GET) {
if (params != null) {
String paramString = URLEncodedUtils.format(params, "UTF-8");
url += "?" + paramString;
}
HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("Cache-Control", "no-cache");
httpResponse = httpClient.execute(httpGet);

}
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

return response;

}

有替代品吗?如果是这样,应该用什么代替?

谢谢

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com