【问题标题】:HttpClient class is deprecatedHttpClient 类已弃用
【发布时间】:2015-06-08 07:53:46
【问题描述】:

我正在我的 android 应用程序中的注册页面上工作,并且我已经成功完成,没有任何错误。但我有一个问题。某些类显示为已弃用。

            HttpClient httpClient = new DefaultHttpClient();
            HttpContext httpContext = new BasicHttpContext();

            HttpGet httpGet = new HttpGet(url);

            try {
                HttpResponse response = httpClient
                        .execute(httpGet, httpContext);

                InputStream inputStream = response.getEntity().getContent();

                input = (inputStreamToString(inputStream).toString())
                        .replaceAll("\\s+", "");
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

在这段代码中,HttpClient、HttpContext、HttpGet、HttpResponse、HttpClient、ClientProtocolException 显示为已弃用。这有什么问题吗?如何在我的应用程序中使用最新的课程?

【问题讨论】:

  • 使用 HttpUrlConnection 代替 Apache 的客户端

标签: android httpclient deprecated


【解决方案1】:

您可以使用HttpURLConnection 类代替检查documentation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多