Contents

Views 3448 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
1137 Develop OGNL(Object Graph Navigation Language) hooni 2013.04.23 15727
1136 Develop OpenGL 강좌 사이트 모음 hooni 2013.04.23 9637
1135 System/OS OpenSSL로 ROOT CA 생성 및 SSL 인증서 발급하기 hooni 2017.10.28 1455
1134 Develop OPT와 CAS에 대한 자료.. (교수님 메일로 보내드린 자료..) file hooni 2013.04.23 13917
1133 System/OS OSI (Open Systems Interconnection) 개방형 시스템간 상호 접속 file hooni 2013.04.23 10785
1132 System/OS php.ini 설정 안됐을때.. ㅋㅋ hooni 2013.04.23 11639
1131 Algorithm Polynomial time 이란? ㅋㅋ hooni 2013.04.23 22679
1130 System/OS RPA란? 어디에 어떻게 쓰이고 누가 만드나? file hooni 2020.01.28 1355
1129 Etc RSVP 란? file hooni 2017.11.22 981
1128 Database SQL JOIN 정리 (Inner Join & Outer Join) file hooni 2019.11.22 1832
1127 System/OS SSH Passwordless Login Using SSH Keygen in 5 Easy Steps file hooni 2019.11.22 1388
1126 Develop SVN 명령어 (SVN command) hooni 2014.02.28 12137
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 98 Next
/ 98