2

I've been trying to create DefaultHttpClient object with:

HttpClient client = new DefaultHttpClient();

but I'm unable to find this class can't be resolved in my Android Studio. After googling this class, the first result shows the following URL:Link

and it's 404: not found page.

Does anyone know how I can use this function and similar function such as HttpGet?

1 Answer 1

1

Use urlconnection. If i remember correctly, defaulthttpclient is deprecated.

URL url = new URL("http://stackoverflow.com");
URLConnection conn = url.openConnection();
InputStream in = new BufferedInputStream(conn.getInputStream());
Sign up to request clarification or add additional context in comments.

2 Comments

urlconnection is an abstract class
Edited the answer to reflect what I meant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.