不推荐使用HttpClient类

时间:2015-06-08 07:53:47

标签: android httpclient deprecated

我在我的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显示为已弃用。这有什么问题吗?如何将最新的类用于我的应用程序?

1 个答案:

答案 0 :(得分:2)

您可以使用HttpURLConnection课程来检查documentation