Contents

Views 3625 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
105 Develop [asem] CMOS 패스워드 알아내기.. 소스.. file hooni 2003.04.23 8748
104 Develop [api] 인스타그램에서 최신 이미지 가져오기 (Using Instagram API) 20 file hooni 2018.04.05 12572
103 Develop [api] 인스타그램 API Access_Token 발급 방법 (Instagram API) 3 file hooni 2018.04.05 7702
102 System/OS [apache2] Redirect HTTP to HTTPS file hooni 2022.02.03 829
101 Develop [android]개발 가이드 및 한글화 문서 file hooni 2013.04.23 47556
100 PPT [android][ios] 알림(Notification) 기능에 대한 원리와 구현 방안 (APNS포함) file hooni 2013.04.23 37892
99 Develop [android] 화면 전환(가로/세로)시 설정 hooni 2013.04.23 43418
98 Develop [android] 해상도 관련 팁 (dip -> pixel 변환) hooni 2013.04.23 15362
97 Develop [android] 코드에서 문자열로 Resource 가져오기 hooni 2015.07.09 4059
96 Develop [android] 초간단 얼럿 (AlertDialog) hooni 2016.10.21 930
» System/OS [android] 초간단 HTTP, POST 전송 샘플 1 file hooni 2017.02.16 3625
94 PPT [Android] 제스처 자료.. file hooni 2013.05.28 51128
Board Pagination Prev 1 ... 85 86 87 88 89 90 91 92 93 94 ... 98 Next
/ 98