gpt4 book ai didi

java - HttpParams 弃用解决方案

转载 作者:可可西里 更新时间:2023-11-01 17:28:46 24 4
gpt4 key购买 nike

<分区>

我从 codecanyon 获得了一个应用程序源,我将用它来构建我的应用程序。我正在学习android。我发现在一个函数中我收到了名为 HttpParams deprecated 的警告。我的代码如下。谁能建议我如何让它正常工作?

public static boolean IsContestEnabled() {
boolean result = false;


String geturl = DataManager.SIMPLE_BASE_URL + "getContest.php";
HttpParams param = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(param, 4000);
HttpConnectionParams.setSoTimeout(param, 10000);

HttpClient client = new DefaultHttpClient(param);
// Send Httpget request
HttpGet get = new HttpGet(geturl);

try {


HttpResponse responsePOST;
String response = null;

responsePOST = client.execute(get);

HttpEntity resEntity = responsePOST.getEntity();

if (resEntity != null) {

// get response
response = EntityUtils.toString(resEntity);

result = true;

try {

JSONObject c = new JSONObject(response);

String status = c.getString("success");

if (status.equals("1")) {
DataManager.status = status;
} else {
DataManager.status = status;
}


} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}

}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return result;
}

我自己尝试通过 Google 进行一些更改并使用 Stackflow 但它不起作用。让我知道是否有人可以挽救我的一天。谢谢

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