CraZyDroiD
CraZyDroiD

Reputation: 7105

HttpClient class is deprecated

I'm working on a registration page in my android application and i've done it successfully without any errors. But i have one problem. Some classes are shown as deprecated.

            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();
            }

In this piece of code HttpClient,HttpContext,HttpGet,HttpResponse,HttpClient,ClientProtocolException are shown as deprecated. Is there any issues in this? How can i use the latest classes to my application?

Upvotes: 0

Views: 2460

Answers (1)

Prachi
Prachi

Reputation: 2559

You can use HttpURLConnection class instead check documentation

Upvotes: 2

Related Questions