2016-09-19 1 views
-1

일부 클래스가 사용되지 않으므로 아래 코드와 동일한 기능을 제공합니다. Android - Apache에서 사용하지 않는 클래스와 동일

try 
    { 
     DefaultHttpClient httpClient = new DefaultHttpClient(); 
     HttpPost httpPost = new HttpPost(url); 
     HttpResponse httpResponse = httpClient.execute(httpPost); 
     HttpEntity httpEntity = httpResponse.getEntity(); 
     is = httpEntity.getContent(); 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
    } 

지금까지 나는이 작성한하지만 내가 뭔가 내 요청 잘못 생각 나는 예외를 받고 있어요 요청 후

HttpURLConnection httpUrlConnection = null; 
    try 
    { 
     URL mUrl = new URL(url); 
     httpUrlConnection = (HttpURLConnection) mUrl.openConnection(); 
     httpUrlConnection.setRequestMethod("POST"); 
     httpUrlConnection.connect(); 
     is = new BufferedInputStream(httpUrlConnection.getInputStream()); 
     httpUrlConnection.disconnect(); 
    } 
catch(Exception e) 
{ 
    e.printStackTrace(); 
} 

작동하지 않습니다.

+0

'httpUrlConnection.disconnect은() : Build.grade에서 최상위 파일이 라인

buildscript { ... dependencies { classpath 'com.android.tools.build:gradle:1.3.1' } } 

그리고 이러한 응용 프로그램의 수준 build.gradle를 넣어 연결 해제 하시겠습니까? – njzk2

답변

0

아파치 레거시 라이브러리를 사용할 수 있습니다. `무엇이라고 생각합니까 후 당신의 InputStream에 발생,

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 
    useLibrary 'org.apache.http.legacy' 
    ... 
} 
관련 문제