Contents

조회 수 3477 댓글 1
Atachment
첨부 '1'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

라이브러리 안 쓰고 간단한 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 걸렸어요~ 다른걸로 대체하심이 ..

  1. [asem] CMOS 패스워드 알아내기.. 소스..

    Date2003.04.23 CategoryDevelop Byhooni Views8694
    Read More
  2. [api] 인스타그램에서 최신 이미지 가져오기 (Using Instagram API)

    Date2018.04.05 CategoryDevelop Byhooni Views12389
    Read More
  3. [api] 인스타그램 API Access_Token 발급 방법 (Instagram API)

    Date2018.04.05 CategoryDevelop Byhooni Views7581
    Read More
  4. [apache2] Redirect HTTP to HTTPS

    Date2022.02.03 CategorySystem/OS Byhooni Views691
    Read More
  5. [android]개발 가이드 및 한글화 문서

    Date2013.04.23 CategoryDevelop Byhooni Views47518
    Read More
  6. [android][ios] 알림(Notification) 기능에 대한 원리와 구현 방안 (APNS포함)

    Date2013.04.23 CategoryPPT Byhooni Views37853
    Read More
  7. [android] 화면 전환(가로/세로)시 설정

    Date2013.04.23 CategoryDevelop Byhooni Views43373
    Read More
  8. [android] 해상도 관련 팁 (dip -> pixel 변환)

    Date2013.04.23 CategoryDevelop Byhooni Views15335
    Read More
  9. [android] 코드에서 문자열로 Resource 가져오기

    Date2015.07.09 CategoryDevelop Byhooni Views3946
    Read More
  10. [android] 초간단 얼럿 (AlertDialog)

    Date2016.10.21 CategoryDevelop Byhooni Views815
    Read More
  11. [android] 초간단 HTTP, POST 전송 샘플

    Date2017.02.16 CategorySystem/OS Byhooni Views3477
    Read More
  12. [Android] 제스처 자료..

    Date2013.05.28 CategoryPPT Byhooni Views51075
    Read More
Board Pagination Prev 1 ... 85 86 87 88 89 90 91 92 93 94 ... 98 Next
/ 98