Contents

Views 3449 Comment 1
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

라이브러리 안 쓰고 간단한 POST 전송하는 예제

public void postData() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://www.hooni.net/ip.php");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("id", "hooni"));
        nameValuePairs.add(new BasicNameValuePair("passwd", "ok!"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block
    }
}

[출처] http://stackoverflow.com/questions/2938502/sending-post-data-in-android


?
  • ?
    ㄴㄴ 2017.05.04 17:02
    NameValuePair는 안드로이드 스튜디오에서는 Deplicate 걸렸어요~ 다른걸로 대체하심이 ..

List of Articles
No. Category Subject Author Date Views
190 System/OS [unix] 유닉스 csh에서 환경변수 등록 hooni 2003.04.23 11697
189 System/OS [linux] 쉘 스크립트 (Shell Script) hooni 2003.04.23 12064
188 System/OS [linux] 쉘 스크립트에 대한 설명과 예제.. hooni 2003.04.23 13413
187 System/OS asx미디어 정보 기록.. hooni 2003.04.23 20533
186 System/OS 컴파일러 수업 자료(교재 : 컴파일러 입문) file hooni 2003.04.23 21966
185 System/OS [perl] 펄 환경 설정해야 할거 ㅋㅋ hooni 2003.04.23 14992
184 System/OS [linux] vi 편집기 간단한 명령과 환경설정 hooni 2003.04.23 11359
183 System/OS [linux] 리눅스 활용 팁^^ hooni 2003.04.23 14629
182 System/OS [linux] 기본 명령어 (내공쌓기) hooni 2003.04.23 14333
181 System/OS [linux] 간단한 vi편집기 사용 명령 hooni 2003.04.23 13456
180 System/OS [linux] 프로그램 설치방법 (내공쌓기) hooni 2003.04.23 13433
179 System/OS [linux] 계정관리하기(내공쌓기) hooni 2003.04.23 13157
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17