HttpClient library deprecated

2016. 5. 4. 18:15안드로이드 개발

그동안 잘 써왔던 HttpClient 라이브러리가 안드로이드 5.1 이상에서는 deprecate 된 것 같다.


기존에 사용하던 통신용 클래스를 가져와서 새로운 프로젝트에 붙이니 warning이 신나게 붙어서 소스 코드 편집 화면이 노란색으로 물들어 있다. ㅠㅠ


제발 그만 좀 바꾸라고~!


http://stackoverflow.com/questions/29150184/httpentity-is-deprecated-on-android-now-whats-the-alternative


java.net.URL url = new java.net.URL("http://some-server");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");

// read the response
System.out.println("Response Code: " + conn.getResponseCode());
InputStream in = new BufferedInputStream(conn.getInputStream());
String response = org.apache.commons.io.IOUtils.toString(in, "UTF-8");
System.out.println(response);

http://stackoverflow.com/questions/29294479/android-deprecated-apache-module-httpclient-httpresponse-etc